[−][src]Module genpdf::fonts
Fonts, font families and a font cache.
The FontCache
caches all loaded fonts. Fonts are loaded from TTF files with the
Document::load_font_family
method and stored in the FontCache
. A Font
is a
reference to a cached font in the FontCache
. A FontFamily
is a collection of a
regular, a bold, an italic and a bold italic font.
Note: The Font
and FontFamily
structs are only valid for the FontCache
they have been created with. If you dont use the low-level render
module directly, only
use the Document::load_font_family
method to load fonts!
Internals
There are two types of font data: A rusttype::Font
is used to calculate the size of
formatted text. It can be loaded at any time using the FontCache::load_font
method. Once the PDF document is rendered, a printpdf::IndirectFontRef
is used to draw
text in the PDF document. Before a font can be used in a PDF document, it has to be embedded
using the FontCache::load_pdf_fonts
method.
If you use the high-level interface provided by Document
to generate a PDF document, these
steps are done automatically. You only have to manually populate the font cache if you use the
low-level interface in the render
module.
Structs
Font | A reference to a font cached by a |
FontCache | Stores font data that can be referenced by a |
FontFamily | A collection of fonts with different styles. |