mPDF Manual – Fonts & Languages

# Font names

### CSS font-family name

Every font family has a name which is defined in the font file. This is the name by which your computer OS registers and recognises the font family.

This is also the name used in CSS e.g.

### mPDF font-family name

This is the name used by mPDF internally to process fonts. This could be anything you like, but by default mPDF will convert CSS font-family names by removing any spaces and changing to lowercase. Reading the CSS name above, mPDF will look for a "mPDF font-family name" of 'trebuchetms'. This means that this will also work:

Next it will look for a translation in $this->fonttrans in the config_fonts.php file. Imagine that we also wished to recognise 'Trebuchet', we would add: mPDF font-family names should therefore always be lower-case and contain no spaces. When mPDF needs to refer to a specific variant (bold, italic etc.) it will use the mPDF font-family name (lowercase) followed by 'B', 'I', or 'BI' (uppercase). The regular/normal Trebuchet MS will be 'trebuchetms', and the bold variant will be referred to as 'trebuchetmsB'. These mPDF font names are used in other places: • all the other configurable variables in the config_fonts.php use the mPDF font-family name • use the mPDF font name in the config_cp.php file to make it selectively available in certain languages. • if used in the PHP script e.g.$mpdf = new mPDF('','','','trebuchetms');
## Font file name To make a font available to mPDF, you need to specify the Truetype .ttf font files for each variant. These should be defined in config_fonts.php in the array: Each font-family must have a Regular ['R'] file defined - the others (['B']old, ['I']talic, ['BI']bold-italic) are optional. mPDF will try to locate the font-file. If you have defined _MPDF_SYSTEM_TTFONTS at the top of the config_fonts.php file, it will first look for the font-file there. This is useful if you are running mPDF on a computer which already has a folder with TTF fonts in (e.g. on Windows) If the font-file is not there, or _MPDF_SYSTEM_TTFONTS is not defined, mPDF will look in the folder /[your_path_to_mpdf]/ttfonts/ Note that the font-file names are case-sensitive and can contain capitals.