1 //========================================================================
5 // Mapping from character codes to Unicode.
7 // Copyright 2001-2003 Glyph & Cog, LLC
9 //========================================================================
11 #ifndef CHARCODETOUNICODE_H
12 #define CHARCODETOUNICODE_H
16 #ifdef USE_GCC_PRAGMAS
20 #include "CharTypes.h"
22 struct CharCodeToUnicodeString;
24 //------------------------------------------------------------------------
26 class CharCodeToUnicode {
29 // Create the CID-to-Unicode mapping specified by <collection>.
30 // This reads a .cidToUnicode file from disk. Sets the initial
31 // reference count to 1. Returns NULL on failure.
32 static CharCodeToUnicode *parseCIDToUnicode(GString *collectionA);
34 // Create the CharCode-to-Unicode mapping for an 8-bit font.
35 // <toUnicode> is an array of 256 Unicode indexes. Sets the initial
36 // reference count to 1.
37 static CharCodeToUnicode *make8BitToUnicode(Unicode *toUnicode);
39 // Parse a ToUnicode CMap for an 8- or 16-bit font.
40 static CharCodeToUnicode *parseCMap(GString *buf, int nBits);
47 // Return true if this mapping matches the specified <collectionA>.
48 GBool match(GString *collectionA);
50 // Map a CharCode to Unicode.
51 int mapToUnicode(CharCode c, Unicode *u, int size);
55 void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
56 CharCodeToUnicode(GString *collectionA);
57 CharCodeToUnicode(GString *collectionA, Unicode *mapA,
58 CharCode mapLenA, GBool copyMap,
59 CharCodeToUnicodeString *sMapA, int sMapLenA);
64 CharCodeToUnicodeString *sMap;
65 int sMapLen, sMapSize;
69 //------------------------------------------------------------------------
71 #define cidToUnicodeCacheSize 4
73 class CIDToUnicodeCache {
79 // Get the CharCodeToUnicode object for <collection>. Increments
80 // its reference count; there will be one reference for the cache
81 // plus one for the caller of this function. Returns NULL on
83 CharCodeToUnicode *getCIDToUnicode(GString *collection);
87 CharCodeToUnicode *cache[cidToUnicodeCacheSize];