X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=pdf2swf%2Fxpdf%2FCharCodeToUnicode.h;h=605e2bd19d9b29eeaaea560bd1b05d231596b24b;hb=c7432833fe3a6469d63fad135151a92e12877b94;hp=06916c8fabf98937a4a6fe3d7dbb2858aa234863;hpb=b9ddd4a2ed601bc01ddacc69d2522687a93a94ce;p=swftools.git diff --git a/pdf2swf/xpdf/CharCodeToUnicode.h b/pdf2swf/xpdf/CharCodeToUnicode.h index 06916c8..605e2bd 100644 --- a/pdf2swf/xpdf/CharCodeToUnicode.h +++ b/pdf2swf/xpdf/CharCodeToUnicode.h @@ -4,19 +4,25 @@ // // Mapping from character codes to Unicode. // -// Copyright 2001-2002 Glyph & Cog, LLC +// Copyright 2001-2003 Glyph & Cog, LLC // //======================================================================== #ifndef CHARCODETOUNICODE_H #define CHARCODETOUNICODE_H -#ifdef __GNUC__ +#include + +#ifdef USE_GCC_PRAGMAS #pragma interface #endif #include "CharTypes.h" +#if MULTITHREADED +#include "GMutex.h" +#endif + struct CharCodeToUnicodeString; //------------------------------------------------------------------------ @@ -24,10 +30,16 @@ struct CharCodeToUnicodeString; class CharCodeToUnicode { public: - // Create the CID-to-Unicode mapping specified by . - // 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 from the file + // specified by . 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 + // . 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. // is an array of 256 Unicode indexes. Sets the initial @@ -37,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 + // . + void mergeCMap(GString *buf, int nBits); + ~CharCodeToUnicode(); void incRefCnt(); void decRefCnt(); - // Return true if this mapping matches the specified . - GBool match(GString *collectionA); + // Return true if this mapping matches the specified . + GBool match(GString *tagA); + + // Set the mapping for . + void setMapping(CharCode c, Unicode *u, int len); // Map a CharCode to Unicode. int mapToUnicode(CharCode c, Unicode *u, int size); @@ -51,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 . 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 . 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 into the cache, in the most-recently-used position. + void add(CharCodeToUnicode *ctu); private: - CharCodeToUnicode *cache[cidToUnicodeCacheSize]; + CharCodeToUnicode **cache; + int size; }; #endif