Fonts

Prince supports TrueType fonts.

OpenType fonts

Prince supports OpenType fonts that have TrueType outlines, but does not support OpenType fonts that have PostScript (Type 1) outlines.

Generic font families

Prince maps the CSS generic font families to the Microsoft Core Fonts as shown in the table below. The Microsoft Core Fonts are pre-installed on Windows and MacOS X systems but not on Linux systems. To use them on Linux you must install the msttcorefonts package, which is available for most Linux distributions.

Generic family Actual font
serif Times New Roman
sans-serif Arial
monospace Courier New

Redefining the generic font families

The CSS generic font families can be redefined to use different fonts by editing the fonts.css file in the Prince installation. Each font family is defined using a @font-face rule, which maps a font family to an actual font either by name or by filename.

Here is an example of mapping the generic "sans-serif" font family to the local system font called "Trebuchet MS".

fonts.css

@font-face {
    font-family: sans-serif;
    src: local("Trebuchet MS")
}

It is also possible to map the generic font families to local fonts specified by the filename of the TrueType font file. This will usually require using multiple @font-face rules, one for each TrueType font file in the font family, which usually includes four files (normal, bold, italic and bold-italic). Here is an example of mapping the generic "sans-serif" font family to the "Trebuchet MS" font using filenames, assuming that the font is installed in the usual system directory on Linux.

fonts.css

@font-face {
    font-family: sans-serif;
    font-style: normal;
    font-weight: normal;
    src: url("/usr/share/fonts/truetype/msttcorefonts/trebuc.ttf")
}

@font-face {
    font-family: sans-serif;
    font-style: normal;
    font-weight: bold;
    src: url("/usr/share/fonts/truetype/msttcorefonts/trebucbd.ttf")
}

@font-face {
    font-family: sans-serif;
    font-style: italic;
    font-weight: normal;
    src: url("/usr/share/fonts/truetype/msttcorefonts/trebucit.ttf")
}

@font-face {
    font-family: sans-serif;
    font-style: italic;
    font-weight: bold;
    src: url("/usr/share/fonts/truetype/msttcorefonts/trebucbi.ttf")
}