1 //========================================================================
5 // Copyright 1999-2003 Glyph & Cog, LLC
7 //========================================================================
12 #ifdef USE_GCC_PRAGMAS
16 #include "goo/gtypes.h"
21 //------------------------------------------------------------------------
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
31 struct Type1CIndexVal
{
32 int pos
; // absolute position in file
33 int len
; // length, in bytes
36 struct Type1CTopDict
{
47 double underlinePosition
;
48 double underlineThickness
;
52 GBool hasFontMatrix
; // CID fonts are allowed to put their
53 // FontMatrix in the FD instead of the
60 int charStringsOffset
;
72 #define type1CMaxBlueValues 14
73 #define type1CMaxOtherBlues 10
74 #define type1CMaxStemSnap 12
76 struct Type1CPrivateDict
{
79 int blueValues
[type1CMaxBlueValues
];
81 int otherBlues
[type1CMaxOtherBlues
];
83 int familyBlues
[type1CMaxBlueValues
];
85 int familyOtherBlues
[type1CMaxOtherBlues
];
86 int nFamilyOtherBlues
;
94 double stemSnapH
[type1CMaxStemSnap
];
96 double stemSnapV
[type1CMaxStemSnap
];
100 double forceBoldThreshold
;
102 double expansionFactor
;
103 int initialRandomSeed
;
105 double defaultWidthX
;
106 GBool defaultWidthXFP
;
107 double nominalWidthX
;
108 GBool nominalWidthXFP
;
112 GBool isNum
; // true -> number, false -> operator
113 GBool isFP
; // true -> floating point number, false -> int
115 double num
; // if num is true
116 int op
; // if num is false
120 struct Type1CEexecBuf
{
121 FoFiOutputFunc outputFunc
;
123 GBool ascii
; // ASCII encoding?
124 Gushort r1
; // eexec encryption key
125 int line
; // number of eexec chars left on current line
128 //------------------------------------------------------------------------
130 //------------------------------------------------------------------------
132 class FoFiType1C
: public FoFiBase
{
135 // Create a FoFiType1C object from a memory buffer.
136 static FoFiType1C
*make(char *fileA
, int lenA
);
138 // Create a FoFiType1C object from a file on disk.
139 static FoFiType1C
*load(char *fileName
);
141 FoFiType1C(char *fileA
, int lenA
, GBool freeFileDataA
);
142 virtual ~FoFiType1C();
144 // Return the font name.
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();
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
);
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
);
163 // Convert to a Type 0 CIDFont, suitable for embedding in a
164 // PostScript file. <psName> will be used as the PostScript font
166 void convertToCIDType0(char *psName
,
167 FoFiOutputFunc outputFunc
, void *outputStream
);
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
);
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
,
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
);
191 void readFD(int offset
, int length
, Type1CPrivateDict
*pDict
);
192 void readPrivateDict(int offset
, int length
, Type1CPrivateDict
*pDict
);
194 void buildEncoding();
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
);
207 Type1CIndex topDictIdx
;
208 Type1CIndex stringIdx
;
209 Type1CIndex gsubrIdx
;
210 Type1CIndex charStringsIdx
;
212 Type1CTopDict topDict
;
213 Type1CPrivateDict
*privateDicts
;
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