class HexaPDF::Font::CMap

Parent

Represents a CMap, a mapping from character codes to CIDs (character IDs) or to their Unicode value.

See: PDF2.0 s9.7.5, s9.10.3; Adobe Technical Notes #5014 and #5411

Attributes

name[RW]

The name of the CMap.

ordering[RW]

The ordering part of the CMap version.

registry[RW]

The registry part of the CMap version.

supplement[RW]

The supplement part of the CMap version.

wmode[RW]

The writing mode of the CMap: 0 for horizontal, 1 for vertical writing.

Public Class Methods

create_to_unicode_cmap(mapping)

Returns a string containing a ToUnicode CMap that represents the given code to Unicode codepoint mapping.

See: Writer#create_to_unicode_cmap

for_name(name)

Creates a new CMap object by parsing a predefined CMap with the given name.

Raises an error if the given CMap is not found.

new()

Creates a new CMap object.

parse(string)

Creates a new CMap object from the given string which needs to contain a valid CMap file.

predefined?(name)

Returns true if the given name specifies a predefined CMap.

Public Instance Methods

add_cid_mapping(code, cid)

Adds an individual mapping from character code to CID.

add_cid_range(start_code, end_code, start_cid)

Adds a CID range, mapping characters codes from start_code to end_code to CIDs starting with start_cid.

add_codespace_range(first, *rest)

Add a codespace range using an array of ranges for the individual bytes.

This means that the first range is checked against the first byte, the second range against the second byte and so on.

add_unicode_mapping(code, string)

Adds a mapping from character code to Unicode string in UTF-8 encoding.

read_codes(string)

Parses the string and returns all character codes.

An error is raised if the string contains invalid bytes.

to_cid(code)

Returns the CID for the given character code, or 0 if no mapping was found.

to_unicode(code)

Returns the Unicode string in UTF-8 encoding for the given character code, or nil if no mapping was found.

use_cmap(cmap)

Add all mappings from the given CMap to this CMap.