Motivation : I'm a die-hard user of LaTeX which is intrigued by ConTeXt and try to learn enough of it to be able to judge on its usability. For now, I'm limiting myself to Mark IV/LuaTeX (Mark II seems to have stopped evolving). I use the current TeXLive distribution (as packaged by Debian).

I recently stumbled on an unexpected difficulty : Opentype math fonts. The current situation is that a lot of the (few) available Opentype Math fonts can be used "out of the box" ; a bit of exploration shows that some support scripts for these fonts exists in $TEXMF/tex/context/fonts/mkiv/.

However, I have been unable to read, guess or divine the goals or structure of these files. As a consequence, I have been unable to cajole Context to use the following couples of Opentype tex / Opentype math fonts, which have recently become available :

  • GFS Neohellenic / GFS Neohellenic Math (CTAN)
  • Fira Sans / Fira Math
  • STIX Two family (CTAN).

I have been able to use the text fonts ; for example :

\definefontfamily [gfsneohellenic] [serif] [GFSNeohellenic]
\setupbodyfont [gfsneohellenic]

but any attempt to use math fails early. However, using the first two of these may allow to get a correct typesetting of maths with a sans typeface consistent with the text font (see this question for amplification...)

[ On the other hand, using them in LuaLaTeX is a piece of cake : link them to the "right" place, re-run font-cache, and you're set... ]

I am not (yet) familiar enough with the ConTeXt documentation to understand the mkiv/.lfg scripts which seem to be the origin of ConTeXt support for these math fonts.

Question(s) : Where should I look for documentation of this feature ? Or is there some "magic" script allowing for the creation of such scripts ?

  • Are you using ConTeXt standalone? It ships with a typescript stixtwo. Commented May 2, 2018 at 9:34
  • @Henri Menke : no, I use the version packaged in TexLive (I follow Debian testing texlive-full quite closely). Commented May 2, 2018 at 10:24
  • 1
    I had a look at the file listing and found that the stixtwo typescript should also be available in Debian testing. Commented May 2, 2018 at 10:32
  • Now that you have two answers to your questions, you should make up your mind and mark one of them as accepted answer (by clicking on the checkmark ✓). Commented May 3, 2018 at 6:23
  • @Henri Menke : on Debian testing locate stixtwo* doesn't return anything ; ditto for STIX2Text-Regular.otf. Searching packages.debian.org for the same filename (fragments) do not return anything in sid nor in experimental. It is possible that these additions are prepared for an update of the texlive packages not yet uploaded to Debian... Commented May 3, 2018 at 14:47

2 Answers 2


Where should I look for documentation of this feature?

There is a manual which is distributed with ConTeXt standalone, called Fonts out of ConTeXt. It is also sometimes referred to as “the new font manual”.

Or is there some "magic" script allowing for the creation of such scripts?

No, there is no magic script to generate these so-called typescripts. But the structure is straight-forward and it is really easy to roll your own.

The procedure is always the same. You define a typescript for a certain family and assign font files to predefined names. For example

\starttypescript [sans] [fira]
  \definefontsynonym [Sans] [file:FiraSans-Regular.otf] [features=default]

This tells ConTeXt that when the Sans version is requested it should load FiraSans-Regular.otf and apply the default font features to it.

The .lfg files (Lua Font Goodies) are more complicated but you mostly need those if you have to patch math fonts, you want to expose special math font features to ConTeXt, or you have to define virtual fonts. In a first approximation they are usually not needed.

Here is a full, yet simple example for the Fira font.

\starttypescriptcollection [fira]

  \starttypescript [sans] [fira]
    \definefontsynonym [Sans]           [file:FiraSans-Regular.otf]       [features=default]
    \definefontsynonym [SansItalic]     [file:FiraSans-RegularItalic.otf] [features=default]
    \definefontsynonym [SansBold]       [file:FiraSans-Bold.otf]          [features=default]
    \definefontsynonym [SansBoldItalic] [file:FiraSans-BoldItalic.otf]    [features=default]
    \definefontsynonym [SansCaps]       [file:FiraSans-Regular.otf]       [features={default,smallcaps}]

  \starttypescript [mono] [fira]
    \definefontsynonym [Mono]     [file:FiraMono-Medium.otf] [features=default]
    \definefontsynonym [MonoBold] [file:FiraMono-Bold.otf]   [features=default]

  \starttypescript [math] [fira]
    \definefontsynonym [MathRoman] [file:Fira-Math.otf] [features=mathextra]

  \starttypescript [fira]
    \definetypeface [\typescriptone] [rm] [serif] [modern] [default]
    \definetypeface [\typescriptone] [ss] [sans]  [fira]   [default]
    \definetypeface [\typescriptone] [tt] [mono]  [fira]   [default]
    \definetypeface [\typescriptone] [mm] [math]  [fira]   [default]




\input knuth

  R_{\mu\nu} - \frac{1}{2} R g_{\mu\nu} + \Lambda g_{\mu\nu} = \frac{8 \pi G}{c^4} T_{\mu\nu}

#include <stdio.h>

int main() {
    printf("Hello World!\n");


enter image description here

  • Any reason, why you prefer (long and complicated) typescripts over \definefontfamily?
    – DG'
    Commented May 2, 2018 at 10:20
  • @DG' Flexibility and conciseness. I can now choose which files I want for which style. Fira Sans comes in weights ultra light, extra light, light, thin, regular, medium, semibold, bold, and heavy. With my approach I could use the light variant for Sans and the medium one for SansBold. I also have explicit control over the font features for each one. Okay, in a one-page document with a single font I would probably use \definefontfamily as well. Commented May 2, 2018 at 10:24
  • Thanks a lot. This complements nicely DG's answer, and may help me understand this part of ConTeXt... Commented May 2, 2018 at 10:55
  • 1
    @Henri Menke : "It also actually answers the questions you give at the end of your post" : indeed, it does. It leaves me with just the small task of understanding the lot... I have a bit of homework to do before coming back : ConTeXt is ... surprising, to say the least, after a bit more of 30 years of on/off LaTeX use... Commented May 2, 2018 at 12:07
  • 1
    @user2903730 Maybe you are interested in my resources here. I also advise you to read the Unexpected Behavior page in the Garden. Commented May 2, 2018 at 21:57

You can get out of the box opentype math by setting mm (or math) with \definefontfamily:

\definefontfamily [mainface] [ss] [GFS Neohellenic]
\definefontfamily [mainface] [mm] [GFS Neohellenic Math]
\definefontfamily [mainface] [rm] [Latin Modern Sans]
\definefontfamily [mainface] [tt] [Latin Modern Typewriter] [features=none]
\setupbodyfont    [mainface]


\input tufte

    \int_0^\infty t^5 e^{-t}\,dt = 120.


enter image description here

Output of $ pdffont:

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
AJITCU+GFSNeohellenic-Regular        CID Type 0C       Identity-H       yes yes yes     10  0
HALPCL+GFSNeohellenicMath            CID Type 0C       Identity-H       yes yes yes     11  0

Context can find opentype fonts that are installed in the OS. To get a list of available fonts run:

$ mtxrun --script fonts --list --all

If you want to filter the results you can use the option --pattern. For example to list all GFS fonts on your system run:

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

You can find more documentation on the context wiki: http://wiki.contextgarden.net/Command/definefontfamily

  • 2
    You should also add \definetypeface[mainface][ss][sans][modern] and \definetypeface[mainface][tt][mono][modern]. Commented May 2, 2018 at 9:32
  • Thanks a lot. As far as I understand, this is a "quick but reasonable way" to use it with default (hopefully acceptable) options, whereas @henri menke allows for fine tuning enhancing long documents. Commented May 2, 2018 at 10:43
  • Note : when I use \definefontfamily [mainface] [ss] [Latin Modern Sans], pdffonts tellls me that I use a LMSans10-Regular subset (as well as a subset of GFSNeohellenicMath) ; when I do not use it, this becomes a subset of GFSNeohellenic-Regular. I suppose that I have to read the docs in order to understand this... Commented May 2, 2018 at 10:52
  • Apropos your note: That is strange. The order in which the \definefontfamily definitions are called seem to matter. I changed the code.
    – DG'
    Commented May 2, 2018 at 14:39
  • 2
    @HenriMenke the behaviour is the same with typescripts: The first definition in a typescript is selected by default. It's a feature, not a bug.
    – DG'
    Commented May 3, 2018 at 8:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .