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. 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
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
);
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
,
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
);
194 void readFD(int offset
, int length
, Type1CPrivateDict
*pDict
);
195 void readPrivateDict(int offset
, int length
, Type1CPrivateDict
*pDict
);
197 void buildEncoding();
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
);
210 Type1CIndex topDictIdx
;
211 Type1CIndex stringIdx
;
212 Type1CIndex gsubrIdx
;
213 Type1CIndex charStringsIdx
;
215 Type1CTopDict topDict
;
216 Type1CPrivateDict
*privateDicts
;
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