module HexaPDF::FontLoader::FromConfiguration
def self.available_fonts(document)
def self.available_fonts(document) document.config['font.map'].transform_values(&:keys) end
def self.call(document, name, variant: :none, subset: true)
Specifies whether the font should be subset if possible.
+subset+::
The font variant. Normally one of :none, :bold, :italic, :bold_italic.
+variant+::
The name of the font.
+name+::
The PDF document to associate the font wrapper with.
+document+::
the caller once the font is not needed anymore.
The file object representing the font file is *not* closed and if needed must be closed by
'font.map' configuration option.
Returns a TrueType font wrapper for the given font by looking up the needed file in the
def self.call(document, name, variant: :none, subset: true) file = document.config['font.map'].dig(name, variant) return nil if file.nil? unless file.kind_of?(HexaPDF::Font::TrueType::Font) || File.file?(file) raise HexaPDF::Error, "The configured font file #{file} is not a valid value" end FromFile.call(document, file, subset: subset) end