Sublime Forum

How to configure custom fonts, requirements for font_face name and directory structure [Solved]



System: Linux, some Linux, Sublime Text 3, no root access

How do I configure custom fonts?

In Preferences.sublime-settings I have a working example:

"font_face": "Monaco",
"font_size": 12,
"font_options": ["dlig","ss04","no_italic"],

On Linux, user-space fonts are usually stored in $HOME/.fonts.

Here I have e.g.:

|-- ttf
|   |-- No ligatures
|   `-- Variable
`-- web
    |-- eot
    |-- woff
    `-- woff2

The font files in ttf folder look like this:


Nothing I tested so far worked in “font_face”, “JetBrainsMono Regular”, “JetBrainsMono-Regular” … whatever. So there must be some “system” how to provide font names/files.

  • where is Sublime Text 3 looking for font files?
  • if ‘.fonts’ is an option, how should the directory structure look like? Any need for any structure or is ST searching recursively for font files?
  • what type of font files are supported? TTF only?
  • how can I deduce from TTF file what to put in into “font_face”?

I love ST but font management drives me frenzy …




You don’t need to provide font path, just add font name from installed fonts on your system.



Well, these fonts are “installed” in .fonts. All I have is a directory path and a bunch of TTFs.
As I wrote I tried to add the “name”, without success. See my description …



Sublime uses system-specific methods for working with fonts; for Linux is uses fontconfig, which is the standard way for Linux programs to work with and catalog fonts.

This is entirely a fontconfig thing and Sublime doesn’t care. In particular, it’s fontconfig's job to find, catalog and match fonts and all Sublime does is ask it for the appropriate font.

This is why for example different distributions of Linux may seem to use a different interface font in Sublime; it just asks fontconfig for a font named Sans by default, and whatever font the distribution (or you) has decided to map that to is the one that gets used.

fontconfig searches recursively through the font folders it’s configured with, so you can use whatever layout you like in your fonts directory (i.e. the above in your question is fine).

fontconfig can handle many types of fonts; ttf, ttc, otf, pfa, pfb and woff to name just the ones I happen to have currently installed. Sublime works with all of those font types. Presumably it would also work with bitmapped fonts as well, though I’ve never tried that myself.

The bit where you are potentially going wrong here is that the name of the file that stores the font and the name of the font itself can be radically different; you could install My Cool Font from a file named zzz.ttf and it would still work as expected. The name of the font comes from metadata inside of the font file itself.

The easiest way to look something like this up is to use the fontconfig tool fc-list. See the documentation on that if you’re interested in the gory details, but simplistically you want to do something like this in your terminal:

tmartin:dart:~> fc-list : family
Standard Symbols PS
Samyak Oriya
Lohit Kannada
Iosevka Term SS09,Iosevka Term SS09 Medium Oblique
Samyak Devanagari
Iosevka Term SS09,Iosevka Term SS09 Extralight Oblique
Iosevka Term SS09,Iosevka Term SS09 Semibold
Century Schoolbook L
DejaVu Math TeX Gyre
URW Gothic
Serto Jerusalem Outline
Estrangelo Edessa

This will list every font that your system knows by name. This is probably overwhelming, so you may want to send it through less to page it or, if you know something about the name of the font you want you can grep it out; this doesn’t require a full name, just something you think is probably in there:

tmartin:dart:~> fc-list : family | grep -i jetbrains
JetBrains Mono,JetBrains Mono Semi Light
JetBrains Mono,JetBrains Mono Medium
JetBrains Mono,JetBrains Mono Extra Bold
JetBrains Mono,JetBrains Mono ExtraLight
JetBrains Mono,JetBrains Mono Light
JetBrains Mono

All of the items are font names; some will have a comma in them if there are multiple styles. You can include any one you like. So for example any of the following are valid:

"font_face": "JetBrains Mono",
"font_face": "JetBrains Mono Light",
"font_face": "JetBrains Mono Extra Bold"

If you’re not a terminal guy, your Linux disto/window manager likely has some sort of font viewer or configuration tool that would give you the names of fonts that you could use to discover the name as well. There is also other software such as font-manager that can provide this information, though I’ve personally never used any.



@OdatNurd … thanks for your helpful and very complete answer.

I did not think about fontconfig. That solves the issues I had!

1 Like