alexmurray / emacs-snap

GNU Emacs in a snap
https://snapcraft.io/emacs
71 stars 13 forks source link

Emacs doesn't find fonts #41

Closed conanite closed 2 years ago

conanite commented 2 years ago

Using snap with GNU Emacs 28.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2022-05-10, on ubuntu 20.04.4 / linux 5.13.0-44 / xcfe 4.14

When I execute (set-frame-font "DejaVu Sans Mono-14"), emacs shows me this error:

Debugger entered--Lisp error: (error "Font not available" #<font-spec nil nil DejaVu\ Sans\ Mono-14 nil nil nil nil nil nil nil nil nil ((:name . "DejaVu Sans Mono-14") (:user-spec . "DejaVu Sans Mono-14"))>)
  set-face-attribute(default #<frame - /home/conan/.emacs.d/init.el () 0x56277163ca08> :width normal :weight normal :slant normal :font "DejaVu Sans Mono-14")
  set-frame-font("DejaVu Sans Mono-14")
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  command-execute(eval-last-sexp)

I end up with courier everywhere and a very limited selection of alternatives (helvetica, times).

The line (set-frame-font "DejaVu Sans Mono-14") is part of my init.el and causes no problem when I run emacs 26.3 on the same machine, as installed by apt. Fonts display as normal on 26.3.

I don't know what I need to change so that emacs 28 finds the usual fonts in the usual places. Any and all help appreciated!

alexmurray commented 2 years ago

Thanks for reporting this issue but I am unable to reproduce it on an up-to-date Ubuntu 20.04 LTS install. How / where have you installed the DejaVu Sans Mono font? Also do you have any different / peculiar font setup in general?

alexmurray commented 2 years ago

Note my test case is spinning up a brand new, up-to-date Ubuntu 20.04 VM, installing the emacs snap from the stable channel, starting it under a graphical session and then doing M-x eval-expression and then (set-frame-font "DejaVu Sans Mono-14") - so perhaps there is something in your init.el causing this?

conanite commented 2 years ago

I emptied my init.el of many years of accumulated junk and re-added one expression at a time, restarting emacs each time. You were right, it was something in my init.el, and I found the culprit, specifically the last line of this expression :

(setq default-frame-alist
      '((top . 0) (left . 0)
        (cursor-color . "yellow")
        (cursor-type . box)
        (background-color . "black")
        (foreground-color . "white")
        (font . "Noto Sans Mono-9")
        (internal-border-width . 0)
        (border-width . 0)
        (font-backend xft x)))

My apologies, I should have tried this before opening an issue, but thank you for the pointer, very grateful I don't have to look at a screenful of courier again :)

cheers

alexmurray commented 2 years ago

No need to apologise - I am glad you were able to resolve the issue.