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

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

First import

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