class HexaPDF:: Font:: TrueTypeWrapper
Parent | Object |
---|
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 PDF2.0 s9.9.1 at the end).
Additionally, TrueType
fonts are always embedded.
Attributes
Returns the PDF object associated with the wrapper.
Public Class Methods
Creates a new object wrapping the TrueType
font for the PDF document.
The optional argument pdf_object
can be used to set the PDF font object that this wrapper should be associated with. If no object is set, a suitable one is automatically created.
If subset
is true, the font is subset.
Public Instance Methods
Returns true
if the font contains bold glyphs.
Returns a custom Glyph
object which represents the given string
via the given glyph id
.
This functionality can be used to associate a single glyph id with multiple, different strings for replacement glyph purposes. When used in such a way, the used glyph id is often 0 which represents the missing glyph.
Returns a glyph object for the given Unicode codepoint.
The configuration option ‘font.on_missing_glyph’ is invoked if no glyph for a given codepoint is available.
Returns an array of glyph objects representing the characters in the UTF-8 encoded string.
See decode_codepoint
for details.
Encodes the glyph and returns the code string.
Returns the type of the font, i.e. :TrueType.
Returns a Glyph
object for the given glyph ID and str
pair.
The optional argument str
should be the string representation of the glyph. It is possible that multiple strings map to the same glyph (e.g. hyphen and soft-hyphen could be represented by the same glyph).
Note: Although this method is public, it should normally not be used by application code!
Returns true
if the font contains glyphs with an incline (italic or slant).
Returns the scaling factor for converting font units into PDF units.