filters

CharCodeToUnicode.h

00001 //========================================================================
00002 //
00003 // CharCodeToUnicode.h
00004 //
00005 // Mapping from character codes to Unicode.
00006 //
00007 // Copyright 2001-2002 Glyph & Cog, LLC
00008 //
00009 //========================================================================
00010 
00011 #ifndef CHARCODETOUNICODE_H
00012 #define CHARCODETOUNICODE_H
00013 
00014 #include <aconf.h>
00015 
00016 #ifdef USE_GCC_PRAGMAS
00017 #pragma interface
00018 #endif
00019 
00020 #include "CharTypes.h"
00021 
00022 struct CharCodeToUnicodeString;
00023 
00024 //------------------------------------------------------------------------
00025 
00026 class CharCodeToUnicode {
00027 public:
00028 
00029   // Create the CID-to-Unicode mapping specified by <collection>.
00030   // This reads a .cidToUnicode file from disk.  Sets the initial
00031   // reference count to 1.  Returns NULL on failure.
00032   static CharCodeToUnicode *parseCIDToUnicode(GString *collectionA);
00033 
00034   // Create the CharCode-to-Unicode mapping for an 8-bit font.
00035   // <toUnicode> is an array of 256 Unicode indexes.  Sets the initial
00036   // reference count to 1.
00037   static CharCodeToUnicode *make8BitToUnicode(Unicode *toUnicode);
00038 
00039   // Parse a ToUnicode CMap for an 8- or 16-bit font.
00040   static CharCodeToUnicode *parseCMap(GString *buf, int nBits);
00041 
00042   ~CharCodeToUnicode();
00043 
00044   void incRefCnt();
00045   void decRefCnt();
00046 
00047   // Return true if this mapping matches the specified <collectionA>.
00048   GBool match(GString *collectionA);
00049 
00050   // Map a CharCode to Unicode.
00051   int mapToUnicode(CharCode c, Unicode *u, int size);
00052 
00053 private:
00054 
00055   void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
00056   CharCodeToUnicode(GString *collectionA);
00057   CharCodeToUnicode(GString *collectionA, Unicode *mapA,
00058             CharCode mapLenA, GBool copyMap,
00059             CharCodeToUnicodeString *sMapA, int sMapLenA);
00060 
00061   GString *collection;
00062   Unicode *map;
00063   CharCode mapLen;
00064   CharCodeToUnicodeString *sMap;
00065   int sMapLen, sMapSize;
00066   int refCnt;
00067 };
00068 
00069 //------------------------------------------------------------------------
00070 
00071 #define cidToUnicodeCacheSize 4
00072 
00073 class CIDToUnicodeCache {
00074 public:
00075 
00076   CIDToUnicodeCache();
00077   ~CIDToUnicodeCache();
00078 
00079   // Get the CharCodeToUnicode object for <collection>.  Increments
00080   // its reference count; there will be one reference for the cache
00081   // plus one for the caller of this function.  Returns NULL on
00082   // failure.
00083   CharCodeToUnicode *getCIDToUnicode(GString *collection);
00084 
00085 private:
00086 
00087   CharCodeToUnicode *cache[cidToUnicodeCacheSize];
00088 };
00089 
00090 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys