upgrade to xpdf 3.00.
[swftools.git] / pdf2swf / xpdf / FoFiTrueType.h
blobea05eec435b19c8e3c25e9c7e2035afe740907fb
1 //========================================================================
2 //
3 // FoFiTrueType.h
4 //
5 // Copyright 1999-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef FOFITRUETYPE_H
10 #define FOFITRUETYPE_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 #include "gtypes.h"
19 #include "FoFiBase.h"
21 class GHash;
22 struct TrueTypeTable;
23 struct TrueTypeCmap;
25 //------------------------------------------------------------------------
26 // FoFiTrueType
27 //------------------------------------------------------------------------
29 class FoFiTrueType: public FoFiBase {
30 public:
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.
41 int getNumCmaps();
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,
77 Gushort *codeToGID,
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>
84 // entries.
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
92 // <nCIDs> entries.
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);
101 private:
103 FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA);
104 void cvtEncoding(char **encoding,
105 FoFiOutputFunc outputFunc,
106 void *outputStream);
107 void cvtCharStrings(char **encoding,
108 Gushort *codeToGID,
109 FoFiOutputFunc outputFunc,
110 void *outputStream);
111 void cvtSfnts(FoFiOutputFunc outputFunc,
112 void *outputStream, GString *name);
113 void dumpString(Guchar *s, int length,
114 FoFiOutputFunc outputFunc,
115 void *outputStream);
116 Guint computeTableChecksum(Guchar *data, int length);
117 void parse();
118 void readPostTable();
119 int seekTable(char *tag);
121 TrueTypeTable *tables;
122 int nTables;
123 TrueTypeCmap *cmaps;
124 int nCmaps;
125 int nGlyphs;
126 int locaFmt;
127 int bbox[4];
128 GHash *nameToGID;
130 GBool parsedOk;
133 #endif