18.7 Fonts

By far the largest impact on MuPDFs size is given by choosing which fonts to include. Accordingly, there are a range of different options:

/* 
   Choose which fonts to include. 
   By default we include the base 14 PDF fonts, 
   DroidSansFallback from Android for CJK, and 
   Charis SIL from SIL for epub/html. 
   Enable the following defines to AVOID including 
   unwanted fonts. 
*/ 
/* To avoid all noto fonts except CJK, enable: */ 
/* #define TOFU */ 
 
/* To skip the CJK font, enable: (this implicitly enables TOFU_CJK_EXT and TOFU_CJK_LANG) */ 
/* #define TOFU_CJK */ 
 
/* To skip CJK Extension A, enable: (this implicitly enables TOFU_CJK_LANG) */ 
/* #define TOFU_CJK_EXT */ 
 
/* To skip CJK language specific fonts, enable: */ 
/* #define TOFU_CJK_LANG */ 
 
/* To skip the Emoji font, enable: */ 
/* #define TOFU_EMOJI */ 
 
/* To skip the ancient/historic scripts, enable: */ 
/* #define TOFU_HISTORIC */ 
 
/* To skip the symbol font, enable: */ 
/* #define TOFU_SYMBOL */ 
 
/* To skip the SIL fonts, enable: */ 
/* #define TOFU_SIL */ 
 
/* To skip the Base14 fonts, enable: */ 
/* #define TOFU_BASE14 */ 
/* (You probably really dont want to do that except for measurement purposes!) */

If documents require a font that is not present, systems will try to ‘fallback’ to alternative ones. When this is not always successful (or indeed possible) unknown glyphs are often rendered as empty boxes, known informally in the typographic world as ‘Tofu’.

By default MuPDF includes all the fonts it knows about. The configuration options are therefore a matter of choosing which scripts should instead be rendered as tofu.

Accordingly, to drop support for rendering emoji characters, you’d define TOFU_EMOJI.

The largest set of fonts are those for the wide range of worldwide scripts given by the Google Noto fonts. These can be omitted by defining TOFU.