I can't seem to make ConTeXt work with system fonts. Let's take this simple example from another question on tex.SE :

Test text

It won't compile :

$ context aa.tex

mtx-context     | run 1: luatex --fmt="/opt/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en" --jobname="aa" --lua="/opt/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en.lui" --no-parse-first-line --c:currentrun=1 --c:fulljobname="./aa" --c:input="./aa" --c:kindofrun=1 --c:maxnofruns=9 "cont-yes.mkiv"
This is LuaTeX, Version beta-0.81.0 (TeX Live 2016/dev) (rev 5350) 
 \write18 enabled.

system          > callbacks > not registering frozen 'find_format_file'
open source     > 1 > 1 > /opt/context/tex/texmf-context/tex/context/base/cont-yes.mkiv

ConTeXt  ver: 2015.10.09 21:28 MKIV beta  fmt: 2015.10.21  int: english/english

system          > 'cont-new.mkiv' loaded
open source     > 2 > 2 > /opt/context/tex/texmf-context/tex/context/base/cont-new.mkiv
close source    > 2 > 2 > /opt/context/tex/texmf-context/tex/context/base/cont-new.mkiv
system          > files > jobname 'aa', input './aa', result 'aa'
fonts           > latin modern fonts are not preloaded
languages       > language 'en' is active
open source     > 2 > 3 > /data/LédiFrance/catalogues/automatic/aa.tex
resolvers       > modules > 'simplefonts' is loaded
open source     > 3 > 4 > /opt/context/tex/texmf-modules/tex/context/third/simplefonts/t-simplefonts.mkiv
loading         > ConTeXt User Module / Simplefonts
resolvers       > lua > loading file '/opt/context/tex/texmf-modules/tex/context/third/simplefonts/t-simplefonts.lua' succeeded
close source    > 3 > 4 > /opt/context/tex/texmf-modules/tex/context/third/simplefonts/t-simplefonts.mkiv
fonts           > defining > source file 'LiberationSans-Regular.ttf' is not found
backend         > xmp > using file '/opt/context/tex/texmf-context/tex/context/base/lpdf-pdx.xml'
pages           > flushing realpage 1, userpage 1
close source    > 2 > 4 > /data/LédiFrance/catalogues/automatic/aa.tex
close source    > 1 > 4 > /opt/context/tex/texmf-context/tex/context/base/cont-yes.mkiv

!LuaTeX error: cannot find OpenType font file for reading ()
 ==> Fatal error occurred, no output PDF file produced!

mtx-context     | fatal error: return code: 1

If I understand correctly, it fails on defining > source file 'LiberationSans-Regular.ttf' is not found. Yet said file is found by mtx-run (and has read access for all) :

$ mtxrun --script fonts --list --all --pattern=Liberation

liberationmono              liberationmono              /usr/share/fonts/liberation/LiberationMono-Regular.ttf
liberationmonobold          liberationmonobold          /usr/share/fonts/liberation/LiberationMono-Bold.ttf
liberationmonobolditalic    liberationmonobolditalic    /usr/share/fonts/liberation/LiberationMono-BoldItalic.ttf
liberationmonoitalic        liberationmonoitalic        /usr/share/fonts/liberation/LiberationMono-Italic.ttf
liberationmononormal        liberationmono              /usr/share/fonts/liberation/LiberationMono-Regular.ttf
liberationmonoregular       liberationmono              /usr/share/fonts/liberation/LiberationMono-Regular.ttf
liberationsans              liberationsans              /usr/share/fonts/liberation/LiberationSans-Regular.ttf
liberationsansbold          liberationsansbold          /usr/share/fonts/liberation/LiberationSans-Bold.ttf
liberationsansbolditalic    liberationsansbolditalic    /usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf
liberationsansitalic        liberationsansitalic        /usr/share/fonts/liberation/LiberationSans-Italic.ttf
liberationsansnormal        liberationsans              /usr/share/fonts/liberation/LiberationSans-Regular.ttf
liberationsansregular       liberationsans              /usr/share/fonts/liberation/LiberationSans-Regular.ttf
liberationserif             liberationserif             /usr/share/fonts/liberation/LiberationSerif-Regular.ttf
liberationserifbold         liberationserifbold         /usr/share/fonts/liberation/LiberationSerif-Bold.ttf
liberationserifbolditalic   liberationserifbolditalic   /usr/share/fonts/liberation/LiberationSerif-BoldItalic.ttf
liberationserifitalic       liberationserifitalic       /usr/share/fonts/liberation/LiberationSerif-Italic.ttf
liberationserifnormal       liberationserif             /usr/share/fonts/liberation/LiberationSerif-Regular.ttf
liberationserifregular      liberationserif             /usr/share/fonts/liberation/LiberationSerif-Regular.ttf

What am I missing ?

(And BTW, I understand from the answer to the question listed above that simplefonts should be fed with the output of mtx-run, but which column ?)

  • 1
    Which ConTeXt version are you using? TL2016 bet? Both, TL2015 and current beta (2015.10.09 21:28 MKIV beta), work flawlessly with your MWE. Maybe your paths are mixed up. – DG' Oct 26 '15 at 8:50
  • @DG' : Right, but which paths ? I assumed that if mtxrun found the font, context should find it as well ? OSFONTDIR is set to /usr/share/fonts;/home/[myuser]/.fonts, and I'm using the version mentioned in the log. – Skippy le Grand Gourou Oct 26 '15 at 9:27
  • Ah, no time to test further but there is no error when I link the font into $HOME/.fonts… More tests later. – Skippy le Grand Gourou Oct 26 '15 at 9:32
  • Why don't you paste your update as an answer? – DG' Oct 26 '15 at 18:30
  • @DG' : I didn't post the workaround at first, so it wasn't a solution, but with it you're right, it's better in an answer (as pathetic as it might be… :) ). – Skippy le Grand Gourou Oct 26 '15 at 18:57

LuaTeX (or rather kpsepath) does not search fonts directories recursively. even with OSFONTDIR="/usr/share/fonts//" (note two trailing slashes) as suggested. It didn't help, although kpsewhich --var-value=OSFONTDIR gives the expected path.

Use this as a workaround:

mkdir $HOME/.fonts
for ii in $(find /usr/share/fonts -name "*.ttf") $(find /usr/share/fonts -name "*.otf"); do ln -s $ii ~/.fonts/; done

This creates the $HOME/.fonts, directory, add it to OSFONTDIR and links recursively all otf and ttf files from /usr/share/fonts into $HOME/.fonts.

A similar approach:

rm -rf $HOME/.fonts
mkdir $HOME/.fonts
cd $HOME/.fonts
for i in $(echo $OSFONTDIR | sed -e 's/:/ /g') ; do
  for j in $(find $i -type f); do
    ln -s $j .;

The script uses the current $OSFONTDIR value and recurses through the directories to link all font files into $HOME/.fonts. Then update (e.g., $HOME/.bashrc):

| improve this answer | |
  • Just to be clear: You did run mtxrun --script fonts --reload every time you changed $OSFONTDIR or the fonts or anything else, didn't you? – DG' Oct 26 '15 at 20:39
  • I can't say I was that systematic, but I think I did it often enough. – Skippy le Grand Gourou Oct 26 '15 at 21:11

I don't have Liberation on my system, so I can't test, but this should work. The functionality of the module simplefonts has been integrated into the core of context, so you don't need it anymore. And the argument it needs is not in the font script of mtxrun, it's the family name of your font. So in your case, you should try:

\definefontfamily [test] [sans] [Liberation Sans]
\setupbodyfont [test,ss,12pt]
Test text
| improve this answer | |
  • So finally I should use the font name as given by fc-list, as opposite to what is explained in the question I mention above ? – Skippy le Grand Gourou Oct 25 '15 at 8:58
  • Anyway, your sample gives exactly the same error… It's not a problem with Liberation itself, actually I choose Liberation for the question because it's quite common but I first triggered this issue on a OTF font from Dafont. – Skippy le Grand Gourou Oct 25 '15 at 8:59
  • 2
    I can only refer you to a message from the list in which Wolfgang (the guy who wrote this mechanism) explains it. So yes, the answer that Aditya gave in the question you mention appears to be incorrect. – Thomas Oct 25 '15 at 9:35
  • Thanks for the link. Actually it makes things even more confusing : Wolfgang says "The family name is shown when you use the info option", but there is no mention of "Liberation Sans" when doing this (only "liberationsans"), yet this is indeed what appears in (most) GUI software, and he mentions in his next message it should be the name to use… – Skippy le Grand Gourou Oct 25 '15 at 10:04
  • 1
    I never said it wasn't confusing :-). As much as I love this new font mechanism, I have at times given up and written a good old-fashioned typescript because I couldn't make it find the font I wanted to use. And I'm not a huge fan of this idea of making system fonts available. I have disabled searching my system font directories (too much interference with similar fonts and names); when I want to use a font with context, I copy it over to my local texmf tree. That way, I have more control. – Thomas Oct 25 '15 at 12:56

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.