class HexaPDF::Font::TrueType::Table::CmapSubtable

Parent

Generic base class for all cmap subtables.

cmap format 8.0 is currently not implemented because use of the format is discouraged in the specification and no font with a format 8.0 cmap subtable was available for testing.

The preferred cmap format is 12.0 because it supports all of Unicode and allows for fast and memory efficient code-to-gid as well as gid-to-code mappings.

See:

Constants

PLATFORM_MICROSOFT

The platform identifier for Microsoft.

PLATFORM_UNICODE

The platform identifier for Unicode.

Attributes

code_map[RW]

The complete code map.

encoding_id[RW]

The platform-specific encoding identifier.

format[R]

The cmap format or nil if the subtable wasn't read from a file.

gid_map[RW]

The complete gid map.

language[RW]

The language code.

platform_id[RW]

The platform identifier.

Public Class Methods

new(platform_id, encoding_id)

Creates a new subtable.

Public Instance Methods

[](code)

Returns the glyph index for the given character code or nil if the character code is not mapped.

gid_to_code(gid)

Returns a character code for the given glyph index or nil if the given glyph index does not exist or is not mapped to a character code.

Note that some fonts map multiple character codes to the same glyph (e.g. hyphen and minus), i.e. the code-to-glyph mapping is surjective but not injective! In such a case one of the available character codes is returned.

parse!(io, offset) → true or false

Parses the cmap subtable from the IO at the given offset.

If the subtable format is supported, the information is used to populate this object and true is returned. Otherwise nothing is done and false is returned.

unicode?()

Returns true if this subtable contains a Unicode cmap.