2

I want to use a custom font for emacs on arch linux. Therefore, I installed the package ttc-iosevka.

Then I added the following line to my init.el:

(set-frame-font "/usr/share/fonts/TTF/iosevka-medium.ttc")

This file however, can't get loaded.. Running emacs with --debug-init:

Debugger entered--Lisp error: (error "Font not available")

How do I add the font properly? I've never done this and I couldn't find anything on the Internet.

3
  • If you start up M-x ielm and do (x-list-fonts "*") you'll see a list of valid strings you can pass to set-frame-font.
    – g-gundam
    May 16, 2023 at 13:23
  • @g-gundam Great! Is there a way to filter my particular string out? Or in other words. How do I add a font to the list? May 16, 2023 at 13:36
  • 1
    I regret telling you about x-list-fonts, because there's an easier way to do it. See my answer below.
    – g-gundam
    May 16, 2023 at 13:47

1 Answer 1

3

Assuming the font is installed correctly, you can just pass in the name of the font to set-frame-font.

(set-frame-font "Iosevka Fixed")

;; You can also give it a size.
(set-frame-font "Iosevka Fixed 11")

You can see a list of font names from the command line by running:

# simple
fc-list
# better formatting and sorted
fc-list --format="%{family[0]}\n" | sort | uniq 

Local font installation in Linux is really easy too.

  • Copy the font to ~/.local/share/fonts
  • Run fc-cache -fv

It sounds like you installed it from a package which is fine too.

3
  • 1
    Great! This worked. :) May 16, 2023 at 13:48
  • 2
    I figured this out by doing C-h f set-frame-font and reading the docs and then reading the source of the function. I didn't know how to do it before you asked, but I knew how to ask emacs for clues. (I've changed fonts before, but it's been a while, so I didn't remember the details.)
    – g-gundam
    May 16, 2023 at 13:53
  • 1
    Nice to know. I'm new to emacs and so knowing this is brilliant :) May 16, 2023 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.