# fontspec (xelatex) finding fonts by name, installed or in TEXMFHOME

This is related to my other question: fontspec search path in TEXMFHOME

I'm trying to write a package using a specific opentype font through `fontspec`.

Using TeXLive 2013 on a Debian computer (a fellow confirms the same behaviour for Mac OS X) I see the following behaviour:

• Font installed as system font (in ~/.fonts):
`lualatex` finds it by its font name and its file name
`xelatex` finds it by its font name but not by its file name
• Font installed in TEXMFHOME (~/texmf/fonts/opentype/FONT/):
`lualatex` finds it by its font name and its file name
`xelatex` finds it by its file name but not by its font name

Is it really true that xelatex (TeXLive on Linux/Mac at least) does find files only by font name when installed as system font and only by file name when installed in the texmf tree? Or am I missing something?

And if that's true could someone please tell me if it's the same on Windows/other TeX distros?

I'm interested in a most generic answer because I will have to tell the user (for arbitrary OS/distro combinations) where to copy (or link) the font folder after downloading the package.

• On linux it depends on their fontconfig configuration (which is not under the control of texlive). See tug.org/texlive/doc/texlive-en/texlive-en.html#x1-340003.4.4. On windows fontconfig is under control of the texsystem (TL and miktex) and normally "everything works". But be careful with xelatex: it doesn't like if if a font exists twice on a system. – Ulrike Fischer Sep 12 '13 at 8:28
• Does this mean: if I would follow these directions and make fontconfig also look into the TEXMFHOME folders I could also find a font by name that is located in TEXMFHOME? And would this also work the other way round, i.e. finding a system font by filename? – uli_1973 Sep 13 '13 at 9:14
• I don't know, I don't have linux. I only know that fontconfig is used to find fonts. (But I'm not sure what xetex does exactly if you give a filename). – Ulrike Fischer Sep 13 '13 at 9:27

When XeTeX is asked to load a font by its file name, it passes the name to kpathea library, so this works like any other TeX file path searching (e.g. `\input`’d files).

When it is asked to load a font by font name, it will use FontConfig on Linux and Windows, and Core Text font manager on Mac, so whatever fonts they can find, XeTeX will be able to use.

• So, to make that clear to me: a font that is installed in `~/.fonts` on Linux will be found by FontConfig but not by kpathsea. This is right? So if I want a font to be installed in the TEXMF tree (because it will be distributed through TeX distros) and to be found both by Xe- and Lua-LaTeX it has to be called by its filename because XeLaTeX wouldn't find it otherwise in the TEXMF tree. Right? – uli_1973 Sep 13 '13 at 14:18
• Right (although you can configure FontConfig to look for fonts under TEXMF tree, but that is probably not suitable for use case). – Khaled Hosny Sep 13 '13 at 14:54