Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 503

Previous Page 502   Index   Next Page 504

Function Reference
Page 503 of 750
CMaps and the CID-Keyed Font Architecture are described in detail in the Adobe Technical Notes
#5092 and #5099. Detailed information about Adobe Character Collections can be found in the Adobe
Technical Notes #5094, #5093, #5078, #5079, #5080, and #5097. These documents can be downloaded
from the Adobe website at www.adobe.com.
External CMaps cannot be used with Type1 fonts and DynaPDF does not support glyph names to
access CIDs because this format is reserved for use with Type1 fonts.
Working with External CMaps
External CMaps can be used to specify a rich mixture of encodings with fixed and variable code
lengths of up to four bytes per character. Many CJK encodings use a mixture of one- and two-byte
encodings while Unicode encodings use one through four-byte representations.
When working with external CMaps it is important to understand how the mapping works in
conjunction with the string functions in DynaPDF. Practically all string functions in DynaPDF are
available in an Ansi and Wide string version.
The wide string version uses 16 bits or two-bytes per character. So, these functions can be used with
CMaps which support a code length of two, four, or a mixture of two/four byte codes but it is not
possible to access CIDs which are encoded with code lengths of one or three bytes because less than
two bytes cannot be consumed from the source string.
No such restriction is given if the Ansi version is used instead because all code lengths from one
through four bytes can be created from the source string.
The mapping of codes to CIDs works essentially as follows:
The CMap parser initializes a 32 bit variable with the first char code of the string. Depending on the
string format the consumed code length is incremented by one or two bytes. Then it checks whether
a CID is defined for this code. If this is not the case, the next char code is consumed and combined
with the existing code to from a 16, 24, or 32 bit code. The search run continues until the maximum
code length or string end was reached. If no CID is defined for that code the notdef character is
DynaPDF does not know how a string is encoded when using a CID font with an external CMap. So,
functions which output formatted text like WriteFText() can only be used if the CID font was loaded
with a CMap that maps UTF-16 (Unicode) to CIDs (the wide string version must be used in this
Because TrueType fonts have no native notation of CIDs, the usage with CID-keyed OpenType fonts
is preferred. CID-keyed OpenType fonts contain an embedded Type1 font in Compact Font Format
(CFF). This font contains also information about the supported character collection. The supported
character collection of the font must match the one of the CMap file. It is not possible to load an
OpenType font with a CMap that contains a mapping into another character collection.

Previous topic: Predefines CMaps

Next topic: LoadFont