1 //========================================================================
5 // Copyright 1999-2003 Glyph & Cog, LLC
7 //========================================================================
10 #define FOFITRUETYPE_H
14 #ifdef USE_GCC_PRAGMAS
25 //------------------------------------------------------------------------
27 //------------------------------------------------------------------------
29 class FoFiTrueType: public FoFiBase {
32 // Create a FoFiTrueType object from a memory buffer.
33 static FoFiTrueType *make(char *fileA, int lenA);
35 // Create a FoFiTrueType object from a file on disk.
36 static FoFiTrueType *load(char *fileName);
38 virtual ~FoFiTrueType();
40 // Return the number of cmaps defined by this font.
43 // Return the platform ID of the <i>th cmap.
44 int getCmapPlatform(int i);
46 // Return the encoding ID of the <i>th cmap.
47 int getCmapEncoding(int i);
49 // Return the index of the cmap for <platform>, <encoding>. Returns
50 // -1 if there is no corresponding cmap.
51 int findCmap(int platform, int encoding);
53 // Return the GID corresponding to <c> according to the <i>th cmap.
54 Gushort mapCodeToGID(int i, int c);
56 // Returns the GID corresponding to <name> according to the post
57 // table. Returns 0 if there is no mapping for <name> or if the
58 // font does not have a post table.
59 int mapNameToGID(char *name);
61 // Returns the least restrictive embedding licensing right (as
62 // defined by the TrueType spec):
63 // * 4: OS/2 table is missing or invalid
64 // * 3: installable embedding
65 // * 2: editable embedding
66 // * 1: preview & print embedding
67 // * 0: restricted license embedding
68 int getEmbeddingRights();
70 // Convert to a Type 42 font, suitable for embedding in a PostScript
71 // file. <psName> will be used as the PostScript font name (so we
72 // don't need to depend on the 'name' table in the font). The
73 // <encoding> array specifies the mapping from char codes to names.
74 // If <encoding> is NULL, the encoding is unknown or undefined. The
75 // <codeToGID> array specifies the mapping from char codes to GIDs.
76 void convertToType42(char *psName, char **encoding,
78 FoFiOutputFunc outputFunc, void *outputStream);
80 // Convert to a Type 2 CIDFont, suitable for embedding in a
81 // PostScript file. <psName> will be used as the PostScript font
82 // name (so we don't need to depend on the 'name' table in the
83 // font). The <cidMap> array maps CIDs to GIDs; it has <nCIDs>
85 void convertToCIDType2(char *psName, Gushort *cidMap, int nCIDs,
86 FoFiOutputFunc outputFunc, void *outputStream);
88 // Convert to a Type 0 (but non-CID) composite font, suitable for
89 // embedding in a PostScript file. <psName> will be used as the
90 // PostScript font name (so we don't need to depend on the 'name'
91 // table in the font). The <cidMap> array maps CIDs to GIDs; it has
93 void convertToType0(char *psName, Gushort *cidMap, int nCIDs,
94 FoFiOutputFunc outputFunc, void *outputStream);
96 // Write a clean TTF file, filling in missing tables and correcting
97 // various other errors. If the font is complete and correct, it
98 // will be written unmodified.
99 void writeTTF(FoFiOutputFunc outputFunc, void *outputStream);
103 FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA);
104 void cvtEncoding(char **encoding,
105 FoFiOutputFunc outputFunc,
107 void cvtCharStrings(char **encoding,
109 FoFiOutputFunc outputFunc,
111 void cvtSfnts(FoFiOutputFunc outputFunc,
112 void *outputStream, GString *name);
113 void dumpString(Guchar *s, int length,
114 FoFiOutputFunc outputFunc,
116 Guint computeTableChecksum(Guchar *data, int length);
118 void readPostTable();
119 int seekTable(char *tag);
121 TrueTypeTable *tables;