fix build with recent changes/gcc 6.3.0
[AROS-Contrib.git] / arospdf / xpdf / CharCodeToUnicode.h
blob7e76675e647febc11bfc6adc446e4308ef77c5e6
1 //========================================================================
2 //
3 // CharCodeToUnicode.h
4 //
5 // Mapping from character codes to Unicode.
6 //
7 // Copyright 2001-2003 Glyph & Cog, LLC
8 //
9 //========================================================================
11 #ifndef CHARCODETOUNICODE_H
12 #define CHARCODETOUNICODE_H
14 #include <aconf.h>
16 #ifdef USE_GCC_PRAGMAS
17 #pragma interface
18 #endif
20 #include "CharTypes.h"
22 #if MULTITHREADED
23 #include "GMutex.h"
24 #endif
26 struct CharCodeToUnicodeString;
28 //------------------------------------------------------------------------
30 class CharCodeToUnicode {
31 public:
33 // Read the CID-to-Unicode mapping for <collection> from the file
34 // specified by <fileName>. Sets the initial reference count to 1.
35 // Returns NULL on failure.
36 static CharCodeToUnicode *parseCIDToUnicode(GString *fileName,
37 GString *collection);
39 // Create a Unicode-to-Unicode mapping from the file specified by
40 // <fileName>. Sets the initial reference count to 1. Returns NULL
41 // on failure.
42 static CharCodeToUnicode *parseUnicodeToUnicode(GString *fileName);
44 // Create the CharCode-to-Unicode mapping for an 8-bit font.
45 // <toUnicode> is an array of 256 Unicode indexes. Sets the initial
46 // reference count to 1.
47 static CharCodeToUnicode *make8BitToUnicode(Unicode *toUnicode);
49 // Parse a ToUnicode CMap for an 8- or 16-bit font.
50 static CharCodeToUnicode *parseCMap(GString *buf, int nBits);
52 // Parse a ToUnicode CMap for an 8- or 16-bit font, merging it into
53 // <this>.
54 void mergeCMap(GString *buf, int nBits);
56 ~CharCodeToUnicode();
58 void incRefCnt();
59 void decRefCnt();
61 // Return true if this mapping matches the specified <tagA>.
62 GBool match(GString *tagA);
64 // Set the mapping for <c>.
65 void setMapping(CharCode c, Unicode *u, int len);
67 // Map a CharCode to Unicode.
68 int mapToUnicode(CharCode c, Unicode *u, int size);
70 // Return the mapping's length, i.e., one more than the max char
71 // code supported by the mapping.
72 CharCode getLength() { return mapLen; }
74 private:
76 void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
77 void addMapping(CharCode code, char *uStr, int n, int offset);
78 CharCodeToUnicode(GString *tagA);
79 CharCodeToUnicode(GString *tagA, Unicode *mapA,
80 CharCode mapLenA, GBool copyMap,
81 CharCodeToUnicodeString *sMapA,
82 int sMapLenA, int sMapSizeA);
84 GString *tag;
85 Unicode *map;
86 CharCode mapLen;
87 CharCodeToUnicodeString *sMap;
88 int sMapLen, sMapSize;
89 int refCnt;
90 #if MULTITHREADED
91 GMutex mutex;
92 #endif
95 //------------------------------------------------------------------------
97 class CharCodeToUnicodeCache {
98 public:
100 CharCodeToUnicodeCache(int sizeA);
101 ~CharCodeToUnicodeCache();
103 // Get the CharCodeToUnicode xObject for <tag>. Increments its
104 // reference count; there will be one reference for the cache plus
105 // one for the caller of this function. Returns NULL on failure.
106 CharCodeToUnicode *getCharCodeToUnicode(GString *tag);
108 // Insert <ctu> into the cache, in the most-recently-used position.
109 void add(CharCodeToUnicode *ctu);
111 private:
113 CharCodeToUnicode **cache;
114 int size;
117 #endif