A *font loader* is a callable object that loads a font based on the given
name and options. If the font loader doesn't have the requested font,
it has to return
The returned object has to be a PDF font wrapper and not the generic font object because it needs to be usable by the PDF canvas. See below for details.
Each font loader is a (stateless) object (normally a module) that has to be callable, i.e. it has to provide the following method:
- call(document, name, **options)
Should return the font wrapper customized for the given document if the font is known or else
options argument is font loader dependent. However, all
font loaders should handle the following common options:
The font variant that should be used (e.g.
A font wrapper needs to provide the following generic interface so that it can be used correctly by HexaPDF:
This method needs to return the PDF font dictionary that represents the wrapped font.
This method needs to convert the given string into an array of glyph objects. The glyph objects themselves have to respond to #width which should return their horizontal width.
This method takes a single glyph object, that needs to be compatible with the font wrapper, and returns an encoded string that can be decoded with the font dictionary returned by #dict.