class HexaPDF::Font::TrueTypeWrapper

Parent

This class wraps a generic TrueType font object and provides the methods needed for working with the font in a PDF context.

TrueType fonts can be represented in two ways in PDF: As a simple font with Subtype TrueType or as a composite font using a Type2 CIDFont. The wrapper only supports the composite font case because:

  • By using a composite font more than 256 characters can be encoded with one font object.

  • Fonts for vertical writing can potentially be used.

  • The PDF specification recommends using a composite font (see PDF1.7 s9.9 at the end).

Additionally, TrueType fonts are always embedded.

Attributes

dict[R]

Returns the PDF font dictionary representing the wrapped font.

wrapped_font[R]

Returns the wrapped TrueType font object.

Public Class Methods

new(document, font, subset: true)

Creates a new object wrapping the TrueType font for the PDF document.

If subset is true, the font is subset.

Public Instance Methods

decode_utf8(str)

Returns an array of glyph objects representing the characters in the UTF-8 encoded string.

encode(glyph)

Encodes the glyph and returns the code string.

font_type()

Returns the type of the font, i.e. :TrueType.

glyph(id, str = nil)

Returns a Glyph object for the given glyph ID.

The optional argument str should be the string representation of the glyph. Only use it if it is known,

Note: Although this method is public, it should normally not be used by application code!

scaling_factor()

Returns the scaling factor for converting font units into PDF units.

subset?()

Returns true if the wrapped TrueType font will be subset.