Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/CharCodeToUnicode.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/xpdf/CharCodeToUnicode.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/CharCodeToUnicode.h b/noncore/unsupported/qpdf/xpdf/CharCodeToUnicode.h new file mode 100644 index 0000000..c811d72 --- a/dev/null +++ b/noncore/unsupported/qpdf/xpdf/CharCodeToUnicode.h | |||
@@ -0,0 +1,89 @@ | |||
1 | //======================================================================== | ||
2 | // | ||
3 | // CharCodeToUnicode.h | ||
4 | // | ||
5 | // Mapping from character codes to Unicode. | ||
6 | // | ||
7 | // Copyright 2001 Derek B. Noonburg | ||
8 | // | ||
9 | //======================================================================== | ||
10 | |||
11 | #ifndef CHARCODETOUNICODE_H | ||
12 | #define CHARCODETOUNICODE_H | ||
13 | |||
14 | #ifdef __GNUC__ | ||
15 | #pragma interface | ||
16 | #endif | ||
17 | |||
18 | #include "CharTypes.h" | ||
19 | |||
20 | struct CharCodeToUnicodeString; | ||
21 | |||
22 | //------------------------------------------------------------------------ | ||
23 | |||
24 | class CharCodeToUnicode { | ||
25 | public: | ||
26 | |||
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); | ||
31 | |||
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); | ||
36 | |||
37 | // Parse a ToUnicode CMap for an 8- or 16-bit font. | ||
38 | static CharCodeToUnicode *parseCMap(GString *buf, int nBits); | ||
39 | |||
40 | ~CharCodeToUnicode(); | ||
41 | |||
42 | void incRefCnt(); | ||
43 | void decRefCnt(); | ||
44 | |||
45 | // Return true if this mapping matches the specified <collectionA>. | ||
46 | GBool match(GString *collectionA); | ||
47 | |||
48 | // Map a CharCode to Unicode. | ||
49 | int mapToUnicode(CharCode c, Unicode *u, int size); | ||
50 | |||
51 | private: | ||
52 | |||
53 | void parseCMap1(char *(*getLineFunc)(char *, int, void *), | ||
54 | void *data, int nBits); | ||
55 | CharCodeToUnicode(GString *collectionA); | ||
56 | CharCodeToUnicode(GString *collectionA, Unicode *mapA, | ||
57 | CharCode mapLenA, GBool copyMap, | ||
58 | CharCodeToUnicodeString *sMapA, int sMapLenA); | ||
59 | |||
60 | GString *collection; | ||
61 | Unicode *map; | ||
62 | CharCode mapLen; | ||
63 | CharCodeToUnicodeString *sMap; | ||
64 | int sMapLen, sMapSize; | ||
65 | int refCnt; | ||
66 | }; | ||
67 | |||
68 | //------------------------------------------------------------------------ | ||
69 | |||
70 | #define cidToUnicodeCacheSize 4 | ||
71 | |||
72 | class CIDToUnicodeCache { | ||
73 | public: | ||
74 | |||
75 | CIDToUnicodeCache(); | ||
76 | ~CIDToUnicodeCache(); | ||
77 | |||
78 | // Get the CharCodeToUnicode object for <collection>. Increments | ||
79 | // its reference count; there will be one reference for the cache | ||
80 | // plus one for the caller of this function. Returns NULL on | ||
81 | // failure. | ||
82 | CharCodeToUnicode *getCIDToUnicode(GString *collection); | ||
83 | |||
84 | private: | ||
85 | |||
86 | CharCodeToUnicode *cache[cidToUnicodeCacheSize]; | ||
87 | }; | ||
88 | |||
89 | #endif | ||