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