File indexing completed on 2025-12-11 10:26:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #ifndef FOFITYPE1C_H
0027 #define FOFITYPE1C_H
0028
0029 #include "FoFiBase.h"
0030
0031 #include "poppler_private_export.h"
0032
0033 #include <set>
0034
0035 class GooString;
0036
0037
0038
0039 struct Type1CIndex
0040 {
0041 int pos;
0042 int len;
0043 int offSize;
0044 int startPos;
0045 int endPos;
0046 };
0047
0048 struct Type1CIndexVal
0049 {
0050 int pos;
0051 int len;
0052 };
0053
0054 struct Type1CTopDict
0055 {
0056 int firstOp;
0057
0058 int versionSID;
0059 int noticeSID;
0060 int copyrightSID;
0061 int fullNameSID;
0062 int familyNameSID;
0063 int weightSID;
0064 int isFixedPitch;
0065 double italicAngle;
0066 double underlinePosition;
0067 double underlineThickness;
0068 int paintType;
0069 int charstringType;
0070 double fontMatrix[6];
0071 bool hasFontMatrix;
0072
0073
0074 int uniqueID;
0075 double fontBBox[4];
0076 double strokeWidth;
0077 int charsetOffset;
0078 int encodingOffset;
0079 int charStringsOffset;
0080 int privateSize;
0081 int privateOffset;
0082
0083
0084 int registrySID;
0085 int orderingSID;
0086 int supplement;
0087 int fdArrayOffset;
0088 int fdSelectOffset;
0089 };
0090
0091 #define type1CMaxBlueValues 14
0092 #define type1CMaxOtherBlues 10
0093 #define type1CMaxStemSnap 12
0094
0095 struct Type1CPrivateDict
0096 {
0097 double fontMatrix[6];
0098 bool hasFontMatrix;
0099 int blueValues[type1CMaxBlueValues];
0100 int nBlueValues;
0101 int otherBlues[type1CMaxOtherBlues];
0102 int nOtherBlues;
0103 int familyBlues[type1CMaxBlueValues];
0104 int nFamilyBlues;
0105 int familyOtherBlues[type1CMaxOtherBlues];
0106 int nFamilyOtherBlues;
0107 double blueScale;
0108 int blueShift;
0109 int blueFuzz;
0110 double stdHW;
0111 bool hasStdHW;
0112 double stdVW;
0113 bool hasStdVW;
0114 double stemSnapH[type1CMaxStemSnap];
0115 int nStemSnapH;
0116 double stemSnapV[type1CMaxStemSnap];
0117 int nStemSnapV;
0118 bool forceBold;
0119 bool hasForceBold;
0120 double forceBoldThreshold;
0121 int languageGroup;
0122 double expansionFactor;
0123 int initialRandomSeed;
0124 int subrsOffset;
0125 double defaultWidthX;
0126 bool defaultWidthXFP;
0127 double nominalWidthX;
0128 bool nominalWidthXFP;
0129 };
0130
0131 struct Type1COp
0132 {
0133 bool isNum = true;
0134 bool isFP = false;
0135 union {
0136 double num = 0;
0137 int op;
0138 };
0139 };
0140
0141 struct Type1CEexecBuf
0142 {
0143 FoFiOutputFunc outputFunc;
0144 void *outputStream;
0145 bool ascii;
0146 unsigned short r1;
0147 int line;
0148 };
0149
0150
0151
0152
0153
0154 class POPPLER_PRIVATE_EXPORT FoFiType1C : public FoFiBase
0155 {
0156 public:
0157
0158 static FoFiType1C *make(const unsigned char *fileA, int lenA);
0159
0160
0161 static FoFiType1C *load(const char *fileName);
0162
0163 ~FoFiType1C() override;
0164
0165
0166 const char *getName() const;
0167
0168
0169
0170 char **getEncoding() const;
0171
0172
0173 int getNumGlyphs() const { return nGlyphs; }
0174 GooString *getGlyphName(int gid) const;
0175
0176
0177
0178 int *getCIDToGIDMap(int *nCIDs) const;
0179
0180
0181 void getFontMatrix(double *mat) const;
0182
0183
0184
0185
0186
0187
0188
0189 void convertToType1(const char *psName, const char **newEncoding, bool ascii, FoFiOutputFunc outputFunc, void *outputStream);
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199 void convertToCIDType0(const char *psName, const int *codeMap, int nCodes, FoFiOutputFunc outputFunc, void *outputStream);
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210 void convertToType0(const char *psName, const int *codeMap, int nCodes, FoFiOutputFunc outputFunc, void *outputStream);
0211
0212 private:
0213 FoFiType1C(const unsigned char *fileA, int lenA, bool freeFileDataA);
0214 void eexecCvtGlyph(Type1CEexecBuf *eb, const char *glyphName, int offset, int nBytes, const Type1CIndex *subrIdx, const Type1CPrivateDict *pDict);
0215 void cvtGlyph(int offset, int nBytes, GooString *charBuf, const Type1CIndex *subrIdx, const Type1CPrivateDict *pDict, bool top, std::set<int> &offsetBeingParsed);
0216 void cvtGlyphWidth(bool useOp, GooString *charBuf, const Type1CPrivateDict *pDict);
0217 void cvtNum(double x, bool isFP, GooString *charBuf) const;
0218 void eexecWrite(Type1CEexecBuf *eb, const char *s) const;
0219 void eexecWriteCharstring(Type1CEexecBuf *eb, const unsigned char *s, int n) const;
0220 void writePSString(const char *s, FoFiOutputFunc outputFunc, void *outputStream) const;
0221 bool parse();
0222 void readTopDict();
0223 void readFD(int offset, int length, Type1CPrivateDict *pDict);
0224 void readPrivateDict(int offset, int length, Type1CPrivateDict *pDict);
0225 void readFDSelect();
0226 void buildEncoding();
0227 bool readCharset();
0228 int getOp(int pos, bool charstring, bool *ok);
0229 int getDeltaIntArray(int *arr, int maxLen) const;
0230 int getDeltaFPArray(double *arr, int maxLen) const;
0231 void getIndex(int pos, Type1CIndex *idx, bool *ok) const;
0232 void getIndexVal(const Type1CIndex *idx, int i, Type1CIndexVal *val, bool *ok) const;
0233 char *getString(int sid, char *buf, bool *ok) const;
0234
0235 GooString *name;
0236 char **encoding;
0237
0238 Type1CIndex nameIdx;
0239 Type1CIndex topDictIdx;
0240 Type1CIndex stringIdx;
0241 Type1CIndex gsubrIdx;
0242 Type1CIndex charStringsIdx;
0243
0244 Type1CTopDict topDict;
0245 Type1CPrivateDict *privateDicts;
0246
0247 int nGlyphs;
0248 int nFDs;
0249 unsigned char *fdSelect;
0250 const unsigned short *charset;
0251 unsigned short charsetLength;
0252 int gsubrBias;
0253
0254 bool parsedOk;
0255
0256 Type1COp ops[49];
0257 int nOps;
0258 int nHints;
0259 bool firstOp;
0260 bool openPath;
0261 };
0262
0263 #endif