module HexaPDF::FontLoader::FromFile

This module interprets the font name either as file name and tries to load it, or as TrueType font object to be wrapped directly.

Public Class Methods

call(document, file_name, subset: true, **) → wrapped_font
call(document, font_object, subset: true, **) → wrapped_font

Returns an appropriate font wrapper for the given file name or TrueType font object.

If a file name is given, the file object representing the font file is not closed and if needed must be closed by the caller once the font is not needed anymore.

The first form using a file name is easier to use in one-off cases. However, if multiple documents always refer to the same font, the second form is better to avoid re-parsing the font file.


The PDF document to associate the font wrapper with.


The file name or a HexaPDF::Font::TrueType::Font object.


Specifies whether the font should be subset if possible.