Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FoFiType1C.h

Go to the documentation of this file.
00001 //========================================================================
00002 //
00003 // FoFiType1C.h
00004 //
00005 // Copyright 1999-2003 Glyph & Cog, LLC
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;                      // absolute position in file
00027   int len;                      // length (number of entries)
00028   int offSize;                  // offset size
00029   int startPos;                 // position of start of index data - 1
00030   int endPos;                   // position one byte past end of the index
00031 };
00032 
00033 struct Type1CIndexVal {
00034   int pos;                      // absolute position in file
00035   int len;                      // length, in bytes
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   // CIDFont entries
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;                  // true -> number, false -> operator
00110   GBool isFP;                   // true -> floating point number, false -> int
00111   union {
00112     double num;                 // if num is true
00113     int op;                     // if num is false
00114   };
00115 };
00116 
00117 struct Type1CEexecBuf {
00118   FoFiOutputFunc outputFunc;
00119   void *outputStream;
00120   GBool ascii;                  // ASCII encoding?
00121   Gushort r1;                   // eexec encryption key
00122   int line;                     // number of eexec chars left on current line
00123 };
00124 
00125 //------------------------------------------------------------------------
00126 // FoFiType1C
00127 //------------------------------------------------------------------------
00128 
00129 class FoFiType1C: public FoFiBase {
00130 public:
00131 
00132   // Create a FoFiType1C object from a memory buffer.
00133   static FoFiType1C *make(char *fileA, int lenA);
00134 
00135   // Create a FoFiType1C object from a file on disk.
00136   static FoFiType1C *load(char *fileName);
00137 
00138   virtual ~FoFiType1C();
00139 
00140   // Return the font name.
00141   char *getName();
00142 
00143   // Return the encoding, as an array of 256 names (any of which may
00144   // be NULL).  This is only useful with 8-bit fonts.
00145   char **getEncoding();
00146 
00147   // Return the mapping from CIDs to GIDs, and return the number of
00148   // CIDs in *<nCIDs>.  This is only useful for CID fonts.
00149   Gushort *getCIDToGIDMap(int *nCIDs);
00150 
00151   // Convert to a Type 1 font, suitable for embedding in a PostScript
00152   // file.  This is only useful with 8-bit fonts.  If <newEncoding> is
00153   // not NULL, it will be used in place of the encoding in the Type 1C
00154   // font.  If <ascii> is true the eexec section will be hex-encoded,
00155   // otherwise it will be left as binary data.
00156   void convertToType1(char **newEncoding, GBool ascii,
00157                       FoFiOutputFunc outputFunc, void *outputStream);
00158 
00159   // Convert to a Type 0 CIDFont, suitable for embedding in a
00160   // PostScript file.  <psName> will be used as the PostScript font
00161   // name.
00162   void convertToCIDType0(char *psName,
00163                          FoFiOutputFunc outputFunc, void *outputStream);
00164 
00165   // Convert to a Type 0 (but non-CID) composite font, suitable for
00166   // embedding in a PostScript file.  <psName> will be used as the
00167   // PostScript font name.
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];             // operands and operator
00221   int nOps;                     // number of operands
00222   int nHints;                   // number of hints for the current glyph
00223   GBool firstOp;                // true if we haven't hit the first op yet
00224 };
00225 
00226 #endif

Generated on Wed Nov 3 12:58:55 2004 for Lemur Toolkit by doxygen1.2.18