module HexaPDF::FontLoader::VariantFromName

This module translates font names like ‘Helvetica bold’ into the arguments ‘Helvetica’ and {variant: :bold}.

This eases the usage of font names where specifying a font variant is not straight-forward. The actual loading of the font is deferred to Document::Fonts#add.

Note that this should be the last entry in the list of font loaders to ensure correct operation.

Public Class Methods

call(document, name, recursive_invocation: false, **options)

Returns a font wrapper for the given font by splitting the font name into the font name part and variant selector part. If the the resulting font cannot be resolved, nil is returned.

A font name should have the form ‘Fontname selector’ where selector can be ‘bold’, ‘italic’ or ‘bold_italic’, for example ‘Helvetica bold’.

Note that a supplied :variant keyword argument is ignored!