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

Last change on this file since 250 was 250, checked in by Eugene Romanenko, 13 years ago

PDF plugin: poppler library updated to version 0.8.3

File size: 3.3 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 {
30friend class UnicodeToCharCode;
31public:
32
33  // Read the CID-to-Unicode mapping for <collection> from the file
34  // specified by <fileName>.  Sets the initial reference count to 1.
35  // Returns NULL on failure.
36  static CharCodeToUnicode *parseCIDToUnicode(GooString *fileName,
37                                              GooString *collection);
38
39  // Create a Unicode-to-Unicode mapping from the file specified by
40  // <fileName>.  Sets the initial reference count to 1.  Returns NULL
41  // on failure.
42  static CharCodeToUnicode *parseUnicodeToUnicode(GooString *fileName);
43
44  // Create the CharCode-to-Unicode mapping for an 8-bit font.
45  // <toUnicode> is an array of 256 Unicode indexes.  Sets the initial
46  // reference count to 1.
47  static CharCodeToUnicode *make8BitToUnicode(Unicode *toUnicode);
48
49  // Parse a ToUnicode CMap for an 8- or 16-bit font.
50  static CharCodeToUnicode *parseCMap(GooString *buf, int nBits);
51  static CharCodeToUnicode *parseCMapFromFile(GooString *fileName, int nBits);
52
53  // Parse a ToUnicode CMap for an 8- or 16-bit font, merging it into
54  // <this>.
55  void mergeCMap(GooString *buf, int nBits);
56
57  ~CharCodeToUnicode();
58
59  void incRefCnt();
60  void decRefCnt();
61
62  // Return true if this mapping matches the specified <tagA>.
63  GBool match(GooString *tagA);
64
65  // Set the mapping for <c>.
66  void setMapping(CharCode c, Unicode *u, int len);
67
68  // Map a CharCode to Unicode.
69  int mapToUnicode(CharCode c, Unicode **u);
70
71  int mapToCharCode(Unicode* u, CharCode *c, int usize);
72
73  // Return the mapping's length, i.e., one more than the max char
74  // code supported by the mapping.
75  CharCode getLength() { return mapLen; }
76
77private:
78
79  void parseCMap1(int (*getCharFunc)(void *), void *data, int nBits);
80  void addMapping(CharCode code, char *uStr, int n, int offset);
81  CharCodeToUnicode(GooString *tagA);
82  CharCodeToUnicode(GooString *tagA, Unicode *mapA,
83                    CharCode mapLenA, GBool copyMap,
84                    CharCodeToUnicodeString *sMapA,
85                    int sMapLenA, int sMapSizeA);
86
87  GooString *tag;
88  Unicode *map;
89  CharCode mapLen;
90  CharCodeToUnicodeString *sMap;
91  int sMapLen, sMapSize;
92  int refCnt;
93#if MULTITHREADED
94  GooMutex mutex;
95#endif
96};
97
98//------------------------------------------------------------------------
99
100class CharCodeToUnicodeCache {
101public:
102
103  CharCodeToUnicodeCache(int sizeA);
104  ~CharCodeToUnicodeCache();
105
106  // Get the CharCodeToUnicode object for <tag>.  Increments its
107  // reference count; there will be one reference for the cache plus
108  // one for the caller of this function.  Returns NULL on failure.
109  CharCodeToUnicode *getCharCodeToUnicode(GooString *tag);
110
111  // Insert <ctu> into the cache, in the most-recently-used position.
112  void add(CharCodeToUnicode *ctu);
113
114private:
115
116  CharCodeToUnicode **cache;
117  int size;
118};
119
120#endif
Note: See TracBrowser for help on using the repository browser.