+//------------------------------------------------------------------------
+// TrueTypeFontFile
+//------------------------------------------------------------------------
+
+struct TTFontTableHdr;
+
+class TrueTypeFontFile: public FontFile {
+public:
+
+ TrueTypeFontFile(char *fileA, int lenA);
+ ~TrueTypeFontFile();
+
+ // This always returns NULL, since it's probably better to trust the
+ // font name in the PDF file rather than the one in the TrueType
+ // font file.
+ virtual char *getName();
+
+ virtual char **getEncoding();
+
+ // Convert to a Type 42 font, suitable for embedding in a PostScript
+ // file. The name will be used as the PostScript font name (so we
+ // don't need to depend on the 'name' table in the font). The
+ // encoding is needed because the PDF Font object can modify the
+ // encoding.
+ void convertToType42(char *name, char **encodingA,
+ CharCodeToUnicode *toUnicode,
+ GBool pdfFontHasEncoding, FILE *out);
+
+ // Convert to a Type 2 CIDFont, suitable for embedding in a
+ // PostScript file. The name will be used as the PostScript font
+ // name (so we don't need to depend on the 'name' table in the
+ // font).
+ void convertToCIDType2(char *name, Gushort *cidMap,
+ int nCIDs, FILE *out);
+
+ // Convert to a Type 0 (but non-CID) composite font, suitable for
+ // embedding in a PostScript file. The name will be used as the
+ // PostScript font name (so we don't need to depend on the 'name'
+ // table in the font).
+ void convertToType0(char *name, Gushort *cidMap,
+ int nCIDs, FILE *out);
+
+ // Write a TTF file, filling in any missing tables that are required
+ // by the TrueType spec. If the font already has all the required
+ // tables, it will be written unmodified.
+ void writeTTF(FILE *out);
+
+private:
+
+ char *file;
+ int len;
+
+ char **encoding;
+
+ TTFontTableHdr *tableHdrs;
+ int nTables;
+ int bbox[4];
+ int locaFmt;
+ int nGlyphs;
+
+ int getByte(int pos);
+ int getChar(int pos);
+ int getUShort(int pos);
+ int getShort(int pos);
+ Guint getULong(int pos);
+ double getFixed(int pos);
+ int seekTable(char *tag);
+ int seekTableIdx(char *tag);
+ void cvtEncoding(char **encodingA, FILE *out);
+ void cvtCharStrings(char **encodingA, CharCodeToUnicode *toUnicode,
+ GBool pdfFontHasEncoding, FILE *out);
+ int getCmapEntry(int cmapFmt, int pos, int code);
+ void cvtSfnts(FILE *out, GString *name);
+ void dumpString(char *s, int length, FILE *out);
+ Guint computeTableChecksum(char *data, int length);
+};
+