all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Error when using Unifont and trying to launch M-x term
@ 2024-05-15 19:46 Rodrigo Morales
  2024-05-16  7:03 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Rodrigo Morales @ 2024-05-15 19:46 UTC (permalink / raw)
  To: help-gnu-emacs



I downloaded the file =unifont-15.1.05.pcf.gz= from https://unifoundry.com/unifont/index.html . I decompressed it using =gunzip= and moved the file to =~/.fonts=. Afterwards, I executed =fc-cache -f=.

I started Emacs using =$ emacs -Q=. I evaluated the following sexp to change the default font.

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

I executed =M-x term=, and I got the message  =window-max-chars-per-line: Invalid font name: -GNU-Unifont-medium-normal-normal-Sans-Serif-16-*-*-*-c-80-iso10646-1= in the minibuffer and =term= wasn't started. I tried executing =M-x term= again but the same message was shown and =term= wasn't started.

The backtrace is shown below. I obtained by starting =emacs -Q= again, enabling =toggle-debug-on-error=, evaluating the same sexp shown above for changing the default font, and executing =M-x term=.

#+BEGIN_SRC text
Debugger entered--Lisp error: (error "Invalid font name: -GNU-Unifont-medium-normal-norm...")
  window-font-width(nil nil)
  window-max-chars-per-line()
  term-mode()
  make-term("terminal" "/bin/zsh" nil)
  term("/bin/zsh")
  funcall-interactively(term "/bin/zsh")
  command-execute(term record)
  execute-extended-command(nil "term" "term")
  funcall-interactively(execute-extended-command nil "term" "term")
  command-execute(execute-extended-command)
#+END_SRC

Why am I getting that error?

* System information

I'm running GNU Emacs 29.3 in Ubuntu 22.04.4 LTS.

#+BEGIN_SRC text
ELISP> (emacs-version)
"GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0)"
#+END_SRC




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Error when using Unifont and trying to launch M-x term
  2024-05-15 19:46 Error when using Unifont and trying to launch M-x term Rodrigo Morales
@ 2024-05-16  7:03 ` Eli Zaretskii
  2024-05-16 19:43   ` Rodrigo Morales
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2024-05-16  7:03 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 15 May 2024 14:46:11 -0500
> From: Rodrigo Morales <me@rodrigomorales.site>
> 
> 
> 
> I downloaded the file =unifont-15.1.05.pcf.gz= from https://unifoundry.com/unifont/index.html . I decompressed it using =gunzip= and moved the file to =~/.fonts=. Afterwards, I executed =fc-cache -f=.
> 
> I started Emacs using =$ emacs -Q=. I evaluated the following sexp to change the default font.
> 
> #+BEGIN_SRC elisp
> (progn
>   (set-fontset-font "fontset-startup" '(#x000000 . #x3FFFFF) "Unifont")
>   (set-fontset-font "fontset-default" '(#x000000 . #x3FFFFF) "Unifont"))
> #+END_SRC
> 
> I executed =M-x term=, and I got the message  =window-max-chars-per-line: Invalid font name: -GNU-Unifont-medium-normal-normal-Sans-Serif-16-*-*-*-c-80-iso10646-1= in the minibuffer and =term= wasn't started. I tried executing =M-x term= again but the same message was shown and =term= wasn't started.
> 
> The backtrace is shown below. I obtained by starting =emacs -Q= again, enabling =toggle-debug-on-error=, evaluating the same sexp shown above for changing the default font, and executing =M-x term=.
> 
> #+BEGIN_SRC text
> Debugger entered--Lisp error: (error "Invalid font name: -GNU-Unifont-medium-normal-norm...")
>   window-font-width(nil nil)
>   window-max-chars-per-line()
>   term-mode()
>   make-term("terminal" "/bin/zsh" nil)
>   term("/bin/zsh")
>   funcall-interactively(term "/bin/zsh")
>   command-execute(term record)
>   execute-extended-command(nil "term" "term")
>   funcall-interactively(execute-extended-command nil "term" "term")
>   command-execute(execute-extended-command)
> #+END_SRC
> 
> Why am I getting that error?

Maybe because you are setting up your fonts and fontsets incorrectly?
For example, you cannot affect the default font, the one used for the
ASCII characters, via set-fontset-font, at least not in the naïve way
you are doing that.  Instead, you should do it the "traditional" way,
by adding this:

  (add-to-list 'default-frame-alist '(font . "Unifont"))

to your init file, and then tell Emacs (again in the init file) that
Unifont should be used for the entire Unicode space of non-ASCII
characters:

  (set-fontset-font t 'unicode "Unifont" nil 'prepend)

In addition, you may need to customize face-font-family-alternatives,
and specifically the alternatives for "Sans Serif" (not sure about
this, but that's where the "-Sans-Serif" suffix above might be coming
from), if the above two measures are still not enough.

Please try the above, and if it also produces an error, report a bug
using "M-x report-emacs-bug RET", with all the details.

P.S. Let me just note, and I will only do this once, that doing all of
that just to have all the lines in "M-x term" be the same height in
110% of cases is IMNSHO too much effort for a little gain.  Your time
and energy will be spent much better by looking at fonts for
characters that make the line height higher, then finding alternative
fonts for those characters which don't have that effect, and
configuring your fontset to use those better fonts for those
problematic characters.  As a nice bonus, this will leave you with
much nicer fonts than Unifont can ever be.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Error when using Unifont and trying to launch M-x term
  2024-05-16  7:03 ` Eli Zaretskii
@ 2024-05-16 19:43   ` Rodrigo Morales
  0 siblings, 0 replies; 3+ messages in thread
From: Rodrigo Morales @ 2024-05-16 19:43 UTC (permalink / raw)
  To: Eli Zaretskii, help-gnu-emacs


Eli Zaretskii <eliz@gnu.org> writes:

> Maybe because you are setting up your fonts and fontsets incorrectly?
> For example, you cannot affect the default font, the one used for the
> ASCII characters, via set-fontset-font, at least not in the naïve way
> you are doing that.  Instead, you should do it the "traditional" way,
> by adding this:
>
>   (add-to-list 'default-frame-alist '(font . "Unifont"))
>
> to your init file, and then tell Emacs (again in the init file) that
> Unifont should be used for the entire Unicode space of non-ASCII
> characters:
>
>   (set-fontset-font t 'unicode "Unifont" nil 'prepend)
>
> In addition, you may need to customize face-font-family-alternatives,
> and specifically the alternatives for "Sans Serif" (not sure about
> this, but that's where the "-Sans-Serif" suffix above might be coming
> from), if the above two measures are still not enough.
>
> Please try the above, and if it also produces an error, report a bug
> using "M-x report-emacs-bug RET", with all the details.

Thanks. I wasn't aware of those methods for setting the default
font. The same error is still being thrown. I have reported a bug:
https://lists.gnu.org/archive/html/bug-gnu-emacs/2024-05/msg00953.html

> P.S. Let me just note, and I will only do this once, that doing all of
> that just to have all the lines in "M-x term" be the same height in
> 110% of cases is IMNSHO too much effort for a little gain.  Your time
> and energy will be spent much better by looking at fonts for
> characters that make the line height higher, then finding alternative
> fonts for those characters which don't have that effect, and
> configuring your fontset to use those better fonts for those
> problematic characters.  As a nice bonus, this will leave you with
> much nicer fonts than Unifont can ever be.

Thanks for the suggestion. I am afraid I didn't make my use case clear:
I value more efficiency over aesthetics so I don't care whether a bitmap
font looks ugly or not. I work with different scripts from different
languages in Emacs, some of these scripts contain characters with
minimal details. For example, consider the following pairs of
characters: 璧壁, 镱镜 and 畲畬. In order to easily different those
characters, I display them with a big size using a OpenType font. A big
font size for ASCII characters is not required, because ASCII characters
can be easily differentiated, so I use an extremely small bitmap font
for ASCII characters, a benefit of doing this is that the most number of
lines fit on my screen and I can read the most information without
scrolling.  A combination of big OpenType fonts and extremely small
bitmap fonts doesn't mix well inside *terminal* because it seems that
*terminal* assumes that all lines have the same height, so some
information in the *terminal* window is displayed out of the limits of
the window. Now, most of my work inside *terminal* involves displaying
ASCII characters so I want to make *terminal* use the extremely small
bitmap font, non-ASCII characters are hardly shown but if they are shown
I want the entire content of *terminal* still fit the window. Here's
another use case: when I am learning new things or I feel tired, I
change the extremely small bitmap font in *terminal* to an OpenType
font, whether a bitmap font or a OpenType font I want the entire
contents of *terminal* to fit the window.

So, the question I really want to solve is: Given one and only one
arbitrary font with an arbitrary size, how can I always ensure that the
information displayed in *terminal* fits the window in its entirety?

Some terminal emulators such as gnome-terminal and kitty are able to fit
the entire content regardless of the characters that are being shown (I
haven't done exhaustive testing on this, but I tried some scenarios). I
think they are able to do that by assigning the same height to all lines
and trying to fit all characters for that height.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-16 19:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-15 19:46 Error when using Unifont and trying to launch M-x term Rodrigo Morales
2024-05-16  7:03 ` Eli Zaretskii
2024-05-16 19:43   ` Rodrigo Morales

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.