Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pdf/xpdf/CharCodeToUnicode.h
diff options
context:
space:
mode:
Diffstat (limited to 'pdf/xpdf/CharCodeToUnicode.h')
-rw-r--r--pdf/xpdf/CharCodeToUnicode.h65
1 files changed, 44 insertions, 21 deletions
diff --git a/pdf/xpdf/CharCodeToUnicode.h b/pdf/xpdf/CharCodeToUnicode.h
index b20f323..605e2bd 100644
--- a/pdf/xpdf/CharCodeToUnicode.h
+++ b/pdf/xpdf/CharCodeToUnicode.h
@@ -19,6 +19,10 @@
#include "CharTypes.h"
+#if MULTITHREADED
+#include "GMutex.h"
+#endif
+
struct CharCodeToUnicodeString;
//------------------------------------------------------------------------
@@ -26,10 +30,16 @@ struct CharCodeToUnicodeString;
class CharCodeToUnicode {
public:
- // Create the CID-to-Unicode mapping specified by <collection>.
- // This reads a .cidToUnicode file from disk. Sets the initial
- // reference count to 1. Returns NULL on failure.
- static CharCodeToUnicode *parseCIDToUnicode(GString *collectionA);
+ // Read the CID-to-Unicode mapping for <collection> from the file
+ // specified by <fileName>. Sets the initial reference count to 1.
+ // Returns NULL on failure.
+ static CharCodeToUnicode *parseCIDToUnicode(GString *fileName,
+ GString *collection);
+
+ // Create a Unicode-to-Unicode mapping from the file specified by
+ // <fileName>. Sets the initial reference count to 1. Returns NULL
+ // on failure.
+ static CharCodeToUnicode *parseUnicodeToUnicode(GString *fileName);
// Create the CharCode-to-Unicode mapping for an 8-bit font.
// <toUnicode> is an array of 256 Unicode indexes. Sets the initial
@@ -39,13 +49,20 @@ public:
// Parse a ToUnicode CMap for an 8- or 16-bit font.
static CharCodeToUnicode *parseCMap(GString *buf, int nBits);
+ // Parse a ToUnicode CMap for an 8- or 16-bit font, merging it into
+ // <this>.
+ void mergeCMap(GString *buf, int nBits);
+
~CharCodeToUnicode();
void incRefCnt();
void decRefCnt();
- // Return true if this mapping matches the specified <collectionA>.
- GBool match(GString *collectionA);
+ // Return true if this mapping matches the specified <tagA>.
+ GBool match(GString *tagA);
+
+ // Set the mapping for <c>.
+ void setMapping(CharCode c, Unicode *u, int len);
// Map a CharCode to Unicode.
int mapToUnicode(CharCode c, Unicode *u, int size);
@@ -53,38 +70,44 @@ public:
private:
void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
- CharCodeToUnicode(GString *collectionA);
- CharCodeToUnicode(GString *collectionA, Unicode *mapA,
+ void addMapping(CharCode code, char *uStr, int n, int offset);
+ CharCodeToUnicode(GString *tagA);
+ CharCodeToUnicode(GString *tagA, Unicode *mapA,
CharCode mapLenA, GBool copyMap,
- CharCodeToUnicodeString *sMapA, int sMapLenA);
+ CharCodeToUnicodeString *sMapA,
+ int sMapLenA, int sMapSizeA);
- GString *collection;
+ GString *tag;
Unicode *map;
CharCode mapLen;
CharCodeToUnicodeString *sMap;
int sMapLen, sMapSize;
int refCnt;
+#ifdef MULTITHREADED
+ GMutex mutex;
+#endif
};
//------------------------------------------------------------------------
-#define cidToUnicodeCacheSize 4
-
-class CIDToUnicodeCache {
+class CharCodeToUnicodeCache {
public:
- CIDToUnicodeCache();
- ~CIDToUnicodeCache();
+ CharCodeToUnicodeCache(int sizeA);
+ ~CharCodeToUnicodeCache();
+
+ // Get the CharCodeToUnicode object for <tag>. Increments its
+ // reference count; there will be one reference for the cache plus
+ // one for the caller of this function. Returns NULL on failure.
+ CharCodeToUnicode *getCharCodeToUnicode(GString *tag);
- // Get the CharCodeToUnicode object for <collection>. Increments
- // its reference count; there will be one reference for the cache
- // plus one for the caller of this function. Returns NULL on
- // failure.
- CharCodeToUnicode *getCIDToUnicode(GString *collection);
+ // Insert <ctu> into the cache, in the most-recently-used position.
+ void add(CharCodeToUnicode *ctu);
private:
- CharCodeToUnicode *cache[cidToUnicodeCacheSize];
+ CharCodeToUnicode **cache;
+ int size;
};
#endif