ConTeXt: Using system-installed TrueType/OpenType fonts

There are three ways to use system fonts.

  1. 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 in type-imp-calibra.mkiv and the typescript for calibiri is defined in type-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):

    \usetypescriptfile[cleartype]
    
    \starttypescript[mainface]
      \definetypeface  [mainface] [rm] [serif] [cambria] [default]
      \definetypeface  [mainface] [ss] [sans]  [calibri] [default]
      \definetypeface  [mainface] [tt] [mono]  [consolas][default]
      \definetypeface  [mainface] [mm] [math]  [cambria] [default]
    \stoptypescript
    
    \setupbodyfont[mainface]
    
    \starttext
    Cambria \sans{Calibri}
    {\em Cambria \sans{Calibri}}
    \stoptext
    

    which gives

    enter image description here

  2. The other option is to use the simplefonts module, which will automatically create appropriate typescript fonts. For example:

    \usemodule[simplefonts]
    
    \setmainfont[Cambria]
    \setsansfont[Calibri]
    

    which gives the same result as before.

  3. In recent versions of ConTeXt MKIV the simplefonts module has been superseded by \definefontfamily which is part of the core.

    \definefontfamily [mainface] [rm] [Cambria]
    \definefontfamily [mainface] [ss] [Calibri]
    \definefontfamily [mainface] [tt] [Consolas]
    \definefontfamily [mainface] [mm] [Asana Math]
    
    \setupbodyfont[mainface]
    

    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.


As easy as executing the following command...

If your OSFONTDIR environment variable is set correctly, then installing (new) system fonts in modern versions of ConTeXt should be as easy as executing the following command:

$ mtxrun --script fonts --reload