From 98a1e3f36567639344f12932b629e526a8783aa8 Mon Sep 17 00:00:00 2001 From: sandman Date: Sat, 13 Apr 2002 00:47:20 +0000 Subject: CVS import of QPdf --- (limited to 'noncore/unsupported/qpdf/xpdf/CharCodeToUnicode.h') diff --git a/noncore/unsupported/qpdf/xpdf/CharCodeToUnicode.h b/noncore/unsupported/qpdf/xpdf/CharCodeToUnicode.h new file mode 100644 index 0000000..c811d72 --- a/dev/null +++ b/noncore/unsupported/qpdf/xpdf/CharCodeToUnicode.h @@ -0,0 +1,89 @@ +//======================================================================== +// +// CharCodeToUnicode.h +// +// Mapping from character codes to Unicode. +// +// Copyright 2001 Derek B. Noonburg +// +//======================================================================== + +#ifndef CHARCODETOUNICODE_H +#define CHARCODETOUNICODE_H + +#ifdef __GNUC__ +#pragma interface +#endif + +#include "CharTypes.h" + +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); + + // Create the CharCode-to-Unicode mapping for an 8-bit font. + // is an array of 256 Unicode indexes. Sets the initial + // reference count to 1. + static CharCodeToUnicode *make8BitToUnicode(Unicode *toUnicode); + + // Parse a ToUnicode CMap for an 8- or 16-bit font. + static CharCodeToUnicode *parseCMap(GString *buf, int nBits); + + ~CharCodeToUnicode(); + + void incRefCnt(); + void decRefCnt(); + + // Return true if this mapping matches the specified . + GBool match(GString *collectionA); + + // Map a CharCode to Unicode. + int mapToUnicode(CharCode c, Unicode *u, int size); + +private: + + void parseCMap1(char *(*getLineFunc)(char *, int, void *), + void *data, int nBits); + CharCodeToUnicode(GString *collectionA); + CharCodeToUnicode(GString *collectionA, Unicode *mapA, + CharCode mapLenA, GBool copyMap, + CharCodeToUnicodeString *sMapA, int sMapLenA); + + GString *collection; + Unicode *map; + CharCode mapLen; + CharCodeToUnicodeString *sMap; + int sMapLen, sMapSize; + int refCnt; +}; + +//------------------------------------------------------------------------ + +#define cidToUnicodeCacheSize 4 + +class CIDToUnicodeCache { +public: + + CIDToUnicodeCache(); + ~CIDToUnicodeCache(); + + // 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); + +private: + + CharCodeToUnicode *cache[cidToUnicodeCacheSize]; +}; + +#endif -- cgit v0.9.0.2