1

Is there a way to use fonts installed in random directories in fontspec without providing the path in each use case?

e.g. I want to use the fonts installed in ~/Library/Fonts.

So far I have only found solutions which suggest providing the path everytime a font is used.

I am looking for a global setting where a variable is set and the directory will be included in the search path for fontspec to use.

2

The solution lays up in the tree of TeX system.

It is in kpathsea library. Which uses /usr/local/texlive/xxxx/texmf.cnf to set search paths for the various types of files the system uses.

So in the above mentioned texmf.cnf file add the following line:

OSFONTDIR = /System/Library/Fonts//;/Library/Fonts//;/Users/username/Library/Fonts//

Where username is the output of the command whoami in Terminal.app.

You can also add other directories, if you don't want to install the fonts you use for typesetting in the regular directories.

You can look at /usr/local/texlive/texmf-dist/web2c/texmf.cnf for furthermore settings that might be useful to you in the future.

To test the setting you've made above run the command:

$ kpsewhich --expand-path '$OSFONTDIR'

Which would output:

/System/Library/Fonts:/Library/Fonts:/Users/username/Library/Fonts

Hope this is helpful enough.

| improve this answer | |
  • 2
    Is the folder not in your fontconfig? – Ulrike Fischer Nov 23 '18 at 11:53
  • 1
    @UlrikeFischer On mac OS X, fontconfig is not used by xetex. – user4686 Nov 23 '18 at 14:57
  • You can also use symlinks from inside ~/Library/Fonts to the TeXLive locations, but this causes problems in case of updates on TeXLive side. I am not sure if your solution add some overhead to lualatex, but at any rate since a few years it should not generate doubles in its database. This looks like nice way for xelatex (I can't test here but +1) – user4686 Nov 23 '18 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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