source: trunk/poppler/mypoppler/poppler/CharCodeToUnicode.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 3.1 KB
Line 
1//========================================================================
2//
3// CharCodeToUnicode.h
4//
5// Mapping from character codes to Unicode.
6//
7// Copyright 2001-2003 Glyph & Cog, LLC
8//
9//========================================================================
10
11#ifndef CHARCODETOUNICODE_H
12#define CHARCODETOUNICODE_H
13
14#ifdef USE_GCC_PRAGMAS
15#pragma interface
16#endif
17
18#include "poppler-config.h"
19#include "CharTypes.h"
20
21#if MULTITHREADED
22#include <goo/GooMutex.h>
23#endif
24
25struct CharCodeToUnicodeString;
26
27//------------------------------------------------------------------------
28
29class CharCodeToUnicode {
30public:
31
32  // Read the CID-to-Unicode mapping for <collection> from the file
33  // specified by <fileName>.  Sets the initial reference count to 1.
34  // Returns NULL on failure.
35  static CharCodeToUnicode *parseCIDToUnicode(GooString *fileName,
36                                              GooString *collection);
37
38  // Create a Unicode-to-Unicode mapping from the file specified by
39  // <fileName>.  Sets the initial reference count to 1.  Returns NULL
40  // on failure.
41  static CharCodeToUnicode *parseUnicodeToUnicode(GooString *fileName);
42
43  // Create the CharCode-to-Unicode mapping for an 8-bit font.
44  // <toUnicode> is an array of 256 Unicode indexes.  Sets the initial
45  // reference count to 1.
46  static CharCodeToUnicode *make8BitToUnicode(Unicode *toUnicode);
47
48  // Parse a ToUnicode CMap for an 8- or 16-bit font.
49  static CharCodeToUnicode *parseCMap(GooString *buf, int nBits);
50
51  // Parse a ToUnicode CMap for an 8- or 16-bit font, merging it into
52  // <this>.
53  void mergeCMap(GooString *buf, int nBits);
54
55  ~CharCodeToUnicode();
56
57  void incRefCnt();
58  void decRefCnt();
59
60  // Return true if this mapping matches the specified <tagA>.
61  GBool match(GooString *tagA);
62
63  // Set the mapping for <c>.
64  void setMapping(CharCode c, Unicode *u, int len);
65
66  // Map a CharCode to Unicode.
67  int mapToUnicode(CharCode c, Unicode *u, int size);
68
69  // Return the mapping's length, i.e., one more than the max char
70  // code supported by the mapping.
71  CharCode getLength() { return mapLen; }
72
73private:
74
75  void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
76  void addMapping(CharCode code, char *uStr, int n, int offset);
77  CharCodeToUnicode(GooString *tagA);
78  CharCodeToUnicode(GooString *tagA, Unicode *mapA,
79                    CharCode mapLenA, GBool copyMap,
80                    CharCodeToUnicodeString *sMapA,
81                    int sMapLenA, int sMapSizeA);
82
83  GooString *tag;
84  Unicode *map;
85  CharCode mapLen;
86  CharCodeToUnicodeString *sMap;
87  int sMapLen, sMapSize;
88  int refCnt;
89#if MULTITHREADED
90  GooMutex mutex;
91#endif
92};
93
94//------------------------------------------------------------------------
95
96class CharCodeToUnicodeCache {
97public:
98
99  CharCodeToUnicodeCache(int sizeA);
100  ~CharCodeToUnicodeCache();
101
102  // Get the CharCodeToUnicode object for <tag>.  Increments its
103  // reference count; there will be one reference for the cache plus
104  // one for the caller of this function.  Returns NULL on failure.
105  CharCodeToUnicode *getCharCodeToUnicode(GooString *tag);
106
107  // Insert <ctu> into the cache, in the most-recently-used position.
108  void add(CharCodeToUnicode *ctu);
109
110private:
111
112  CharCodeToUnicode **cache;
113  int size;
114};
115
116#endif
Note: See TracBrowser for help on using the repository browser.