00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef FOFITYPE1C_H
00010 #define FOFITYPE1C_H
00011
00012 #include <aconf.h>
00013
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017
00018 #include "gtypes.h"
00019 #include "FoFiBase.h"
00020
00021 class GString;
00022
00023
00024
00025 struct Type1CIndex {
00026 int pos;
00027 int len;
00028 int offSize;
00029 int startPos;
00030 int endPos;
00031 };
00032
00033 struct Type1CIndexVal {
00034 int pos;
00035 int len;
00036 };
00037
00038 struct Type1CTopDict {
00039 int firstOp;
00040
00041 int versionSID;
00042 int noticeSID;
00043 int copyrightSID;
00044 int fullNameSID;
00045 int familyNameSID;
00046 int weightSID;
00047 int isFixedPitch;
00048 double italicAngle;
00049 double underlinePosition;
00050 double underlineThickness;
00051 int paintType;
00052 int charstringType;
00053 double fontMatrix[6];
00054 int uniqueID;
00055 double fontBBox[4];
00056 double strokeWidth;
00057 int charsetOffset;
00058 int encodingOffset;
00059 int charStringsOffset;
00060 int privateSize;
00061 int privateOffset;
00062
00063
00064 int registrySID;
00065 int orderingSID;
00066 int supplement;
00067 int fdArrayOffset;
00068 int fdSelectOffset;
00069 };
00070
00071 #define type1CMaxBlueValues 14
00072 #define type1CMaxOtherBlues 10
00073 #define type1CMaxStemSnap 12
00074
00075 struct Type1CPrivateDict {
00076 int blueValues[type1CMaxBlueValues];
00077 int nBlueValues;
00078 int otherBlues[type1CMaxOtherBlues];
00079 int nOtherBlues;
00080 int familyBlues[type1CMaxBlueValues];
00081 int nFamilyBlues;
00082 int familyOtherBlues[type1CMaxOtherBlues];
00083 int nFamilyOtherBlues;
00084 double blueScale;
00085 int blueShift;
00086 int blueFuzz;
00087 double stdHW;
00088 GBool hasStdHW;
00089 double stdVW;
00090 GBool hasStdVW;
00091 double stemSnapH[type1CMaxStemSnap];
00092 int nStemSnapH;
00093 double stemSnapV[type1CMaxStemSnap];
00094 int nStemSnapV;
00095 GBool forceBold;
00096 GBool hasForceBold;
00097 double forceBoldThreshold;
00098 int languageGroup;
00099 double expansionFactor;
00100 int initialRandomSeed;
00101 int subrsOffset;
00102 double defaultWidthX;
00103 GBool defaultWidthXFP;
00104 double nominalWidthX;
00105 GBool nominalWidthXFP;
00106 };
00107
00108 struct Type1COp {
00109 GBool isNum;
00110 GBool isFP;
00111 union {
00112 double num;
00113 int op;
00114 };
00115 };
00116
00117 struct Type1CEexecBuf {
00118 FoFiOutputFunc outputFunc;
00119 void *outputStream;
00120 GBool ascii;
00121 Gushort r1;
00122 int line;
00123 };
00124
00125
00126
00127
00128
00129 class FoFiType1C: public FoFiBase {
00130 public:
00131
00132
00133 static FoFiType1C *make(char *fileA, int lenA);
00134
00135
00136 static FoFiType1C *load(char *fileName);
00137
00138 virtual ~FoFiType1C();
00139
00140
00141 char *getName();
00142
00143
00144
00145 char **getEncoding();
00146
00147
00148
00149 Gushort *getCIDToGIDMap(int *nCIDs);
00150
00151
00152
00153
00154
00155
00156 void convertToType1(char **newEncoding, GBool ascii,
00157 FoFiOutputFunc outputFunc, void *outputStream);
00158
00159
00160
00161
00162 void convertToCIDType0(char *psName,
00163 FoFiOutputFunc outputFunc, void *outputStream);
00164
00165
00166
00167
00168 void convertToType0(char *psName,
00169 FoFiOutputFunc outputFunc, void *outputStream);
00170
00171 private:
00172
00173 FoFiType1C(char *fileA, int lenA, GBool freeFileDataA);
00174 void eexecCvtGlyph(Type1CEexecBuf *eb, char *glyphName,
00175 int offset, int nBytes,
00176 Type1CIndex *subrIdx,
00177 Type1CPrivateDict *pDict);
00178 void cvtGlyph(int offset, int nBytes, GString *charBuf,
00179 Type1CIndex *subrIdx, Type1CPrivateDict *pDict,
00180 GBool top);
00181 void cvtGlyphWidth(GBool useOp, GString *charBuf,
00182 Type1CPrivateDict *pDict);
00183 void cvtNum(double x, GBool isFP, GString *charBuf);
00184 void eexecWrite(Type1CEexecBuf *eb, char *s);
00185 void eexecWriteCharstring(Type1CEexecBuf *eb, Guchar *s, int n);
00186 GBool parse();
00187 void readTopDict();
00188 void readFD(int offset, int length, Type1CPrivateDict *pDict);
00189 void readPrivateDict(int offset, int length, Type1CPrivateDict *pDict);
00190 void readFDSelect();
00191 void buildEncoding();
00192 GBool readCharset();
00193 int getOp(int pos, GBool charstring, GBool *ok);
00194 int getDeltaIntArray(int *arr, int maxLen);
00195 int getDeltaFPArray(double *arr, int maxLen);
00196 void getIndex(int pos, Type1CIndex *idx, GBool *ok);
00197 void getIndexVal(Type1CIndex *idx, int i, Type1CIndexVal *val, GBool *ok);
00198 char *getString(int sid, char *buf, GBool *ok);
00199
00200 GString *name;
00201 char **encoding;
00202
00203 Type1CIndex nameIdx;
00204 Type1CIndex topDictIdx;
00205 Type1CIndex stringIdx;
00206 Type1CIndex gsubrIdx;
00207 Type1CIndex charStringsIdx;
00208
00209 Type1CTopDict topDict;
00210 Type1CPrivateDict *privateDicts;
00211
00212 int nGlyphs;
00213 int nFDs;
00214 Guchar *fdSelect;
00215 Gushort *charset;
00216 int gsubrBias;
00217
00218 GBool parsedOk;
00219
00220 Type1COp ops[49];
00221 int nOps;
00222 int nHints;
00223 GBool firstOp;
00224 };
00225
00226 #endif