I'm trying to use Cambria for text and Calibri for headings in a ConTeXt document, but I don't understand what is happening at all, nothing seems to have any effect and in the end it falls back to LMRoman/LMSans.
As a minimal starting point, I'm trying to recreate this document. I can just compile it with lualatex
and it finds my fonts, they are installed system-wide through fontconfig. pdffonts
shows that two TrueType faces from each family are embedded, nothing else.
\documentclass{minimal}
\usepackage{fontspec}
\setmainfont{Cambria}
\setsansfont{Calibri}
\begin{document}
Cambria \textsf{Calibri}
\emph{Cambria \textsf{Calibri}}
\end{document}
How do I create this document using ConTeXt? I tried this:
\setupbodyfont[Cambria]
%no idea how to set sans
\starttext
Cambria \sans{Calibri}
\em{Cambria \sans{Calibri}}
\stoptext
But only got LM, the log contained an error about loc
, which isn't mentioned in my file, is this a bug in the typefile? It seems to try to do something with the argument but fails before loading…
fonts > typescripts > unknown library 'loc'
(/usr/local/texlive/2013/texmf-dist/tex/context/base/type-imp-cambria.mkiv)
As far as I understand, both fontspec and ConTeXt use luatex' facilities to locate and load the fonts, so I don't have to install them manually, is that true? In my installation, type-otf.mkiv
is empty except for a comment claiming that it's unnecessary since OTF fonts can be found by name.
With
\setupbodyfont[libertine]
\starttext ...
I get Biolinum as the roman font and Libertine as sans, but only for the first \sans
, everything in \em
is roman.
Best Answer
There are three ways to use system fonts.
Write your own typescript. ConTeXt comes with the typescripts for most system fonts. See
type-imp-*.mkiv
for details. For example, the typescript for calibra is defined intype-imp-calibra.mkiv
and the typescript forcalibiri
is defined intype-imp-cleartype.mkiv
. To use them, you need to define your own typescript that sets the serif and sans serif fonts. For example (not that\em
is font switch, not a font command):which gives
The other option is to use the
simplefonts
module, which will automatically create appropriate typescript fonts. For example:which gives the same result as before.
In recent versions of ConTeXt MKIV the
simplefonts
module has been superseded by\definefontfamily
which is part of the core.This has the same effect as the above. Keep in mind though that you have to set all typefaces, i.e.
rm
,ss
,tt
,mm
. Otherwise strange things might happen.