Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CharCodeToUnicode.h

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

Generated on Sat Nov 5 16:18:13 2005 for OPIE by  doxygen 1.4.2