DynaPDF Manual - Page 551
Previous Page 550 Index Next Page 552
Page 551 of 821
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.
One CMap file can be used with an arbitrary number of CID fonts. The function checks whether a
CMap was already loaded before it loads the same CMap again. A CMap specifies also the writing
mode. The style flag fsVerticalMode will be ignored when loading a font with an external CMap.
Previous topic: Predefines CMaps
Next topic: LoadFont