unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Rodrigo Morales <me@rodrigomorales.site>
To: <help-gnu-emacs@gnu.org>
Subject: [Question] How to change the height of the box for unprintable glyphs?
Date: Wed, 15 May 2024 12:37:43 -0500	[thread overview]
Message-ID: <6aad61b5057ea92af6fd5f9daef953bc@rodrigomorales.site> (raw)


* The context

In some of my use cases, I feel the need to use a bitmap font in a =*terminal*= buffer.

Some days ago, I noticed that some lines in a =*terminal*= buffer were shown with a different height. This caused the tmux status bar when it is shown at the top to be shown out of the =*terminal*= buffer. This is undesired behavior. I learned that this happened because Emacs tries to display some characters using different fonts which might have different heights. For this reason, I started looking for a bitmap font which defines glyphs for all Unicode characters. Thus, by using a single font, the height of all lines would be the same. I found GNU Unifont.

I downloaded the file =unifont-15.1.05.pcf.gz= from https://unifoundry.com/unifont/ . Then, I decompressed the file using =gunzip= and copied the file =unifont-15.1.05.bdf= to =~/.fonts=. Finally, I executed =fc-cache -f -v=.

I launched =emacs -Q /tmp/a.txt= (the contents of =/tmp/a.txt= are shown in the first code block below).

#+HEADER: :tangle /tmp/a.txt
#+BEGIN_SRC text
Line 1: Hello!
Line 2: 你好!
Line 3: 𑂩𑂰𑂧𑂩𑂰𑂧 ("Hello" in Kaithi, retrieved from HELLO buffer in GNU Emacs 29.3)
#+END_SRC

I then tried to make Emacs display all characters only using Unifont. If the glyph is not defined by Unifont, then a box with the hexadecimal notation of the character should be shown. I accomplished this by evaluating the following sexpL

#+HEADER: :results silent
#+BEGIN_SRC elisp
(progn
 (set-fontset-font "fontset-startup" '(#x000000 . #x3FFFFF) "Unifont")
 (set-fontset-font "fontset-default" '(#x000000 . #x3FFFFF) "Unifont"))
#+END_SRC

Upon evaluation of the sexp, all characters in the buffer =a.txt= except characters in line 3 were shown using GNU Unifont, boxes with hexadecimal notation were shown in line 3. See screenshot in http://web.archive.org/web/20240515172349/http://0x0.st/XK5h.png

The boxes shown in line 3 significantly increased the height of that line. =(line-pixel-height= returned 16 in line 1 and line 2, but it returned 37 in line 3.

* The question

How to reduce the height of the rectangle containing hexadecimal notation that Emacs uses to display characters for which no font was found?

* The XY problem

To avoid [[https://www.perlmonks.org/?node_id=542341][the XY problem]], I want to make clear that my main goal is to use a bitmap font in a =*terminal*= buffer and ensure that all lines have the same height (the X). One way that I found to accomplish this is by using a bitmap font that defines glyphs for most characters. However, this raised the problem that undefined glyphs are shown with a larger height (the Y).



             reply	other threads:[~2024-05-15 17:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-15 17:37 Rodrigo Morales [this message]
2024-05-15 18:27 ` [Question] How to change the height of the box for unprintable glyphs? Eli Zaretskii
2024-05-15 21:28   ` Rodrigo Morales
2024-05-16 19:08     ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-05-16 19:35       ` Eli Zaretskii
2024-05-17 14:12         ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-05-15 19:26 ` Rodrigo Morales

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6aad61b5057ea92af6fd5f9daef953bc@rodrigomorales.site \
    --to=me@rodrigomorales.site \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).