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

Last change on this file since 515 was 515, checked in by Silvan Scherrer, 9 years ago

updated poppler to 0.20.3

File size: 7.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  // Get the glyph names.
165  int getNumGlyphs() { return nGlyphs; }
166  GooString *getGlyphName(int gid);
167
168  // Return the mapping from CIDs to GIDs, and return the number of
169  // CIDs in *<nCIDs>.  This is only useful for CID fonts.
170  int *getCIDToGIDMap(int *nCIDs);
171
172  // Return the font matrix as an array of six numbers.
173  void getFontMatrix(double *mat);
174
175  // Convert to a Type 1 font, suitable for embedding in a PostScript
176  // file.  This is only useful with 8-bit fonts.  If <newEncoding> is
177  // not NULL, it will be used in place of the encoding in the Type 1C
178  // font.  If <ascii> is true the eexec section will be hex-encoded,
179  // otherwise it will be left as binary data.  If <psName> is non-NULL,
180  // it will be used as the PostScript font name.
181  void convertToType1(char *psName, const char **newEncoding, GBool ascii,
182                      FoFiOutputFunc outputFunc, void *outputStream);
183
184  // Convert to a Type 0 CIDFont, suitable for embedding in a
185  // PostScript file.  <psName> will be used as the PostScript font
186  // name.  There are three cases for the CID-to-GID mapping:
187  // (1) if <codeMap> is non-NULL, then it is the CID-to-GID mapping
188  // (2) if <codeMap> is NULL and this is a CID CFF font, then the
189  //     font's internal CID-to-GID mapping is used
190  // (3) is <codeMap> is NULL and this is an 8-bit CFF font, then
191  //     the identity CID-to-GID mapping is used
192  void convertToCIDType0(char *psName, int *codeMap, int nCodes,
193                         FoFiOutputFunc outputFunc, void *outputStream);
194
195  // Convert to a Type 0 (but non-CID) composite font, suitable for
196  // embedding in a PostScript file.  <psName> will be used as the
197  // PostScript font name.  There are three cases for the CID-to-GID
198  // mapping:
199  // (1) if <codeMap> is non-NULL, then it is the CID-to-GID mapping
200  // (2) if <codeMap> is NULL and this is a CID CFF font, then the
201  //     font's internal CID-to-GID mapping is used
202  // (3) is <codeMap> is NULL and this is an 8-bit CFF font, then
203  //     the identity CID-to-GID mapping is used
204  void convertToType0(char *psName, int *codeMap, int nCodes,
205                      FoFiOutputFunc outputFunc, void *outputStream);
206
207private:
208
209  FoFiType1C(char *fileA, int lenA, GBool freeFileDataA);
210  void eexecCvtGlyph(Type1CEexecBuf *eb, const char *glyphName,
211                     int offset, int nBytes,
212                     Type1CIndex *subrIdx,
213                     Type1CPrivateDict *pDict);
214  void cvtGlyph(int offset, int nBytes, GooString *charBuf,
215                Type1CIndex *subrIdx, Type1CPrivateDict *pDict,
216                GBool top);
217  void cvtGlyphWidth(GBool useOp, GooString *charBuf,
218                     Type1CPrivateDict *pDict);
219  void cvtNum(double x, GBool isFP, GooString *charBuf);
220  void eexecWrite(Type1CEexecBuf *eb, const char *s);
221  void eexecWriteCharstring(Type1CEexecBuf *eb, Guchar *s, int n);
222  void writePSString(char *s, FoFiOutputFunc outputFunc, void *outputStream);
223  GBool parse();
224  void readTopDict();
225  void readFD(int offset, int length, Type1CPrivateDict *pDict);
226  void readPrivateDict(int offset, int length, Type1CPrivateDict *pDict);
227  void readFDSelect();
228  void buildEncoding();
229  GBool readCharset();
230  int getOp(int pos, GBool charstring, GBool *ok);
231  int getDeltaIntArray(int *arr, int maxLen);
232  int getDeltaFPArray(double *arr, int maxLen);
233  void getIndex(int pos, Type1CIndex *idx, GBool *ok);
234  void getIndexVal(Type1CIndex *idx, int i, Type1CIndexVal *val, GBool *ok);
235  char *getString(int sid, char *buf, GBool *ok);
236
237  GooString *name;
238  char **encoding;
239
240  Type1CIndex nameIdx;
241  Type1CIndex topDictIdx;
242  Type1CIndex stringIdx;
243  Type1CIndex gsubrIdx;
244  Type1CIndex charStringsIdx;
245
246  Type1CTopDict topDict;
247  Type1CPrivateDict *privateDicts;
248
249  int nGlyphs;
250  int nFDs;
251  Guchar *fdSelect;
252  Gushort *charset;
253  int gsubrBias;
254
255  GBool parsedOk;
256
257  Type1COp ops[49];             // operands and operator
258  int nOps;                     // number of operands
259  int nHints;                   // number of hints for the current glyph
260  GBool firstOp;                // true if we haven't hit the first op yet
261  GBool openPath;               // true if there is an unclosed path
262};
263
264#endif
Note: See TracBrowser for help on using the repository browser.