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