source: trunk/poppler/mypoppler/fofi/FoFiType1C.h @ 461

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

PDF plugin: Poppler library updated to version 0.10.0

File size: 6.9 KB
Line 
1//========================================================================
2//
3// FoFiType1C.h
4//
5// Copyright 1999-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9//========================================================================
10//
11// Modified under the Poppler project - http://poppler.freedesktop.org
12//
13// All changes made under the Poppler project to this file are licensed
14// under GPL version 2 or later
15//
16// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
17//
18// To see a description of the changes please see the Changelog file that
19// came with your tarball or type make ChangeLog if you are building from git
20//
21//========================================================================
22
23#ifndef FOFITYPE1C_H
24#define FOFITYPE1C_H
25
26#ifdef USE_GCC_PRAGMAS
27#pragma interface
28#endif
29
30#include "goo/gtypes.h"
31#include "FoFiBase.h"
32
33class GooString;
34
35//------------------------------------------------------------------------
36
37struct Type1CIndex {
38  int pos;                      // absolute position in file
39  int len;                      // length (number of entries)
40  int offSize;                  // offset size
41  int startPos;                 // position of start of index data - 1
42  int endPos;                   // position one byte past end of the index
43};
44
45struct Type1CIndexVal {
46  int pos;                      // absolute position in file
47  int len;                      // length, in bytes
48};
49
50struct Type1CTopDict {
51  int firstOp;
52
53  int versionSID;
54  int noticeSID;
55  int copyrightSID;
56  int fullNameSID;
57  int familyNameSID;
58  int weightSID;
59  int isFixedPitch;
60  double italicAngle;
61  double underlinePosition;
62  double underlineThickness;
63  int paintType;
64  int charstringType;
65  double fontMatrix[6];
66  GBool hasFontMatrix;          // CID fonts are allowed to put their
67                                //   FontMatrix in the FD instead of the
68                                //   top dict
69  int uniqueID;
70  double fontBBox[4];
71  double strokeWidth;
72  int charsetOffset;
73  int encodingOffset;
74  int charStringsOffset;
75  int privateSize;
76  int privateOffset;
77
78  // CIDFont entries
79  int registrySID;
80  int orderingSID;
81  int supplement;
82  int fdArrayOffset;
83  int fdSelectOffset;
84};
85
86#define type1CMaxBlueValues 14
87#define type1CMaxOtherBlues 10
88#define type1CMaxStemSnap   12
89
90struct Type1CPrivateDict {
91  double fontMatrix[6];
92  GBool hasFontMatrix;
93  int blueValues[type1CMaxBlueValues];
94  int nBlueValues;
95  int otherBlues[type1CMaxOtherBlues];
96  int nOtherBlues;
97  int familyBlues[type1CMaxBlueValues];
98  int nFamilyBlues;
99  int familyOtherBlues[type1CMaxOtherBlues];
100  int nFamilyOtherBlues;
101  double blueScale;
102  int blueShift;
103  int blueFuzz;
104  double stdHW;
105  GBool hasStdHW;
106  double stdVW;
107  GBool hasStdVW;
108  double stemSnapH[type1CMaxStemSnap];
109  int nStemSnapH;
110  double stemSnapV[type1CMaxStemSnap];
111  int nStemSnapV;
112  GBool forceBold;
113  GBool hasForceBold;
114  double forceBoldThreshold;
115  int languageGroup;
116  double expansionFactor;
117  int initialRandomSeed;
118  int subrsOffset;
119  double defaultWidthX;
120  GBool defaultWidthXFP;
121  double nominalWidthX;
122  GBool nominalWidthXFP;
123};
124
125struct Type1COp {
126  GBool isNum;                  // true -> number, false -> operator
127  GBool isFP;                   // true -> floating point number, false -> int
128  union {
129    double num;                 // if num is true
130    int op;                     // if num is false
131  };
132};
133
134struct Type1CEexecBuf {
135  FoFiOutputFunc outputFunc;
136  void *outputStream;
137  GBool ascii;                  // ASCII encoding?
138  Gushort r1;                   // eexec encryption key
139  int line;                     // number of eexec chars left on current line
140};
141
142//------------------------------------------------------------------------
143// FoFiType1C
144//------------------------------------------------------------------------
145
146class FoFiType1C: public FoFiBase {
147public:
148
149  // Create a FoFiType1C object from a memory buffer.
150  static FoFiType1C *make(char *fileA, int lenA);
151
152  // Create a FoFiType1C object from a file on disk.
153  static FoFiType1C *load(char *fileName);
154
155  virtual ~FoFiType1C();
156
157  // Return the font name.
158  char *getName();
159
160  // Return the encoding, as an array of 256 names (any of which may
161  // be NULL).  This is only useful with 8-bit fonts.
162  char **getEncoding();
163
164  // Return the mapping from CIDs to GIDs, and return the number of
165  // CIDs in *<nCIDs>.  This is only useful for CID fonts.
166  Gushort *getCIDToGIDMap(int *nCIDs);
167
168  // Convert to a Type 1 font, suitable for embedding in a PostScript
169  // file.  This is only useful with 8-bit fonts.  If <newEncoding> is
170  // not NULL, it will be used in place of the encoding in the Type 1C
171  // font.  If <ascii> is true the eexec section will be hex-encoded,
172  // otherwise it will be left as binary data.  If <psName> is non-NULL,
173  // it will be used as the PostScript font name.
174  void convertToType1(char *psName, char **newEncoding, GBool ascii,
175                      FoFiOutputFunc outputFunc, void *outputStream);
176
177  // Convert to a Type 0 CIDFont, suitable for embedding in a
178  // PostScript file.  <psName> will be used as the PostScript font
179  // name.
180  void convertToCIDType0(char *psName,
181                         FoFiOutputFunc outputFunc, void *outputStream);
182
183  // Convert to a Type 0 (but non-CID) composite font, suitable for
184  // embedding in a PostScript file.  <psName> will be used as the
185  // PostScript font name.
186  void convertToType0(char *psName,
187                      FoFiOutputFunc outputFunc, void *outputStream);
188
189private:
190
191  FoFiType1C(char *fileA, int lenA, GBool freeFileDataA);
192  void eexecCvtGlyph(Type1CEexecBuf *eb, char *glyphName,
193                     int offset, int nBytes,
194                     Type1CIndex *subrIdx,
195                     Type1CPrivateDict *pDict);
196  void cvtGlyph(int offset, int nBytes, GooString *charBuf,
197                Type1CIndex *subrIdx, Type1CPrivateDict *pDict,
198                GBool top);
199  void cvtGlyphWidth(GBool useOp, GooString *charBuf,
200                     Type1CPrivateDict *pDict);
201  void cvtNum(double x, GBool isFP, GooString *charBuf);
202  void eexecWrite(Type1CEexecBuf *eb, char *s);
203  void eexecWriteCharstring(Type1CEexecBuf *eb, Guchar *s, int n);
204  GBool parse();
205  void readTopDict();
206  void readFD(int offset, int length, Type1CPrivateDict *pDict);
207  void readPrivateDict(int offset, int length, Type1CPrivateDict *pDict);
208  void readFDSelect();
209  void buildEncoding();
210  GBool readCharset();
211  int getOp(int pos, GBool charstring, GBool *ok);
212  int getDeltaIntArray(int *arr, int maxLen);
213  int getDeltaFPArray(double *arr, int maxLen);
214  void getIndex(int pos, Type1CIndex *idx, GBool *ok);
215  void getIndexVal(Type1CIndex *idx, int i, Type1CIndexVal *val, GBool *ok);
216  char *getString(int sid, char *buf, GBool *ok);
217
218  GooString *name;
219  char **encoding;
220
221  Type1CIndex nameIdx;
222  Type1CIndex topDictIdx;
223  Type1CIndex stringIdx;
224  Type1CIndex gsubrIdx;
225  Type1CIndex charStringsIdx;
226
227  Type1CTopDict topDict;
228  Type1CPrivateDict *privateDicts;
229
230  int nGlyphs;
231  int nFDs;
232  Guchar *fdSelect;
233  Gushort *charset;
234  int gsubrBias;
235
236  GBool parsedOk;
237
238  Type1COp ops[49];             // operands and operator
239  int nOps;                     // number of operands
240  int nHints;                   // number of hints for the current glyph
241  GBool firstOp;                // true if we haven't hit the first op yet
242  GBool openPath;               // true if there is an unclosed path
243};
244
245#endif
Note: See TracBrowser for help on using the repository browser.