1 //========================================================================
5 // Copyright 1999-2003 Glyph & Cog, LLC
7 //========================================================================
14 #ifdef USE_GCC_PRAGMAS
23 //------------------------------------------------------------------------
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
{
49 double underlinePosition
;
50 double underlineThickness
;
54 GBool hasFontMatrix
; // CID fonts are allowed to put their
55 // FontMatrix in the FD instead of the
62 int charStringsOffset
;
74 #define type1CMaxBlueValues 14
75 #define type1CMaxOtherBlues 10
76 #define type1CMaxStemSnap 12
78 struct Type1CPrivateDict
{
81 int blueValues
[type1CMaxBlueValues
];
83 int otherBlues
[type1CMaxOtherBlues
];
85 int familyBlues
[type1CMaxBlueValues
];
87 int familyOtherBlues
[type1CMaxOtherBlues
];
88 int nFamilyOtherBlues
;
96 double stemSnapH
[type1CMaxStemSnap
];
98 double stemSnapV
[type1CMaxStemSnap
];
102 double forceBoldThreshold
;
104 double expansionFactor
;
105 int initialRandomSeed
;
107 double defaultWidthX
;
108 GBool defaultWidthXFP
;
109 double nominalWidthX
;
110 GBool nominalWidthXFP
;
114 GBool isNum
; // true -> number, false -> operator
115 GBool isFP
; // true -> floating point number, false -> int
117 double num
; // if num is true
118 int op
; // if num is false
122 struct Type1CEexecBuf
{
123 FoFiOutputFunc outputFunc
;
125 GBool ascii
; // ASCII encoding?
126 Gushort r1
; // eexec encryption key
127 int line
; // number of eexec chars left on current line
130 //------------------------------------------------------------------------
132 //------------------------------------------------------------------------
134 class FoFiType1C
: public FoFiBase
{
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.
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.
161 void convertToType1(char **newEncoding
, GBool ascii
,
162 FoFiOutputFunc outputFunc
, void *outputStream
);
164 // Convert to a Type 0 CIDFont, suitable for embedding in a
165 // PostScript file. <psName> will be used as the PostScript font
167 void convertToCIDType0(char *psName
,
168 FoFiOutputFunc outputFunc
, void *outputStream
);
170 // Convert to a Type 0 (but non-CID) composite font, suitable for
171 // embedding in a PostScript file. <psName> will be used as the
172 // PostScript font name.
173 void convertToType0(char *psName
,
174 FoFiOutputFunc outputFunc
, void *outputStream
);
178 FoFiType1C(char *fileA
, int lenA
, GBool freeFileDataA
);
179 void eexecCvtGlyph(Type1CEexecBuf
*eb
, char *glyphName
,
180 int offset
, int nBytes
,
181 Type1CIndex
*subrIdx
,
182 Type1CPrivateDict
*pDict
);
183 void cvtGlyph(int offset
, int nBytes
, GString
*charBuf
,
184 Type1CIndex
*subrIdx
, Type1CPrivateDict
*pDict
,
186 void cvtGlyphWidth(GBool useOp
, GString
*charBuf
,
187 Type1CPrivateDict
*pDict
);
188 void cvtNum(double x
, GBool isFP
, GString
*charBuf
);
189 void eexecWrite(Type1CEexecBuf
*eb
, char *s
);
190 void eexecWriteCharstring(Type1CEexecBuf
*eb
, Guchar
*s
, int n
);
193 void readFD(int offset
, int length
, Type1CPrivateDict
*pDict
);
194 void readPrivateDict(int offset
, int length
, Type1CPrivateDict
*pDict
);
196 void buildEncoding();
198 int getOp(int pos
, GBool charstring
, GBool
*ok
);
199 int getDeltaIntArray(int *arr
, int maxLen
);
200 int getDeltaFPArray(double *arr
, int maxLen
);
201 void getIndex(int pos
, Type1CIndex
*idx
, GBool
*ok
);
202 void getIndexVal(Type1CIndex
*idx
, int i
, Type1CIndexVal
*val
, GBool
*ok
);
203 char *getString(int sid
, char *buf
, GBool
*ok
);
209 Type1CIndex topDictIdx
;
210 Type1CIndex stringIdx
;
211 Type1CIndex gsubrIdx
;
212 Type1CIndex charStringsIdx
;
214 Type1CTopDict topDict
;
215 Type1CPrivateDict
*privateDicts
;
225 Type1COp ops
[49]; // operands and operator
226 int nOps
; // number of operands
227 int nHints
; // number of hints for the current glyph
228 GBool firstOp
; // true if we haven't hit the first op yet
229 GBool openPath
; // true if there is an unclosed path