modified makefile to allow easier adjustment of build options for different targets...
[AROS-Contrib.git] / arospdf / fofi / FoFiTrueType.h
blobcf06ae78a9e3f1c91bf12621bad6f19820275110
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 GString;
22 class GHash;
23 struct TrueTypeTable;
24 struct TrueTypeCmap;
26 //------------------------------------------------------------------------
27 // FoFiTrueType
28 //------------------------------------------------------------------------
30 class FoFiTrueType: public FoFiBase {
31 public:
33 // Create a FoFiTrueType object from a memory buffer.
34 static FoFiTrueType *make(char *fileA, int lenA);
36 // Create a FoFiTrueType object from a file on disk.
37 static FoFiTrueType *load(char *fileName);
39 virtual ~FoFiTrueType();
41 // Returns true if this an OpenType font containing CFF data, false
42 // if it's a TrueType font (or OpenType font with TrueType data).
43 GBool isOpenTypeCFF() { return openTypeCFF; }
45 // Return the number of cmaps defined by this font.
46 int getNumCmaps();
48 // Return the platform ID of the <i>th cmap.
49 int getCmapPlatform(int i);
51 // Return the encoding ID of the <i>th cmap.
52 int getCmapEncoding(int i);
54 // Return the index of the cmap for <platform>, <encoding>. Returns
55 // -1 if there is no corresponding cmap.
56 int findCmap(int platform, int encoding);
58 // Return the GID corresponding to <c> according to the <i>th cmap.
59 Gushort mapCodeToGID(int i, int c);
61 // Returns the GID corresponding to <name> according to the post
62 // table. Returns 0 if there is no mapping for <name> or if the
63 // font does not have a post table.
64 int mapNameToGID(char *name);
66 // Return the mapping from CIDs to GIDs, and return the number of
67 // CIDs in *<nCIDs>. This is only useful for CID fonts. (Only
68 // useful for OpenType CFF fonts.)
69 Gushort *getCIDToGIDMap(int *nCIDs);
71 // Returns the least restrictive embedding licensing right (as
72 // defined by the TrueType spec):
73 // * 4: OS/2 table is missing or invalid
74 // * 3: installable embedding
75 // * 2: editable embedding
76 // * 1: preview & print embedding
77 // * 0: restricted license embedding
78 int getEmbeddingRights();
80 // Convert to a Type 42 font, suitable for embedding in a PostScript
81 // file. <psName> will be used as the PostScript font name (so we
82 // don't need to depend on the 'name' table in the font). The
83 // <encoding> array specifies the mapping from char codes to names.
84 // If <encoding> is NULL, the encoding is unknown or undefined. The
85 // <codeToGID> array specifies the mapping from char codes to GIDs.
86 // (Not useful for OpenType CFF fonts.)
87 void convertToType42(char *psName, char **encoding,
88 Gushort *codeToGID,
89 FoFiOutputFunc outputFunc, void *outputStream);
91 // Convert to a Type 1 font, suitable for embedding in a PostScript
92 // file. This is only useful with 8-bit fonts. If <newEncoding> is
93 // not NULL, it will be used in place of the encoding in the Type 1C
94 // font. If <ascii> is true the eexec section will be hex-encoded,
95 // otherwise it will be left as binary data. If <psName> is
96 // non-NULL, it will be used as the PostScript font name. (Only
97 // useful for OpenType CFF fonts.)
98 void convertToType1(char *psName, char **newEncoding, GBool ascii,
99 FoFiOutputFunc outputFunc, void *outputStream);
101 // Convert to a Type 2 CIDFont, suitable for embedding in a
102 // PostScript file. <psName> will be used as the PostScript font
103 // name (so we don't need to depend on the 'name' table in the
104 // font). The <cidMap> array maps CIDs to GIDs; it has <nCIDs>
105 // entries. (Not useful for OpenType CFF fonts.)
106 void convertToCIDType2(char *psName, Gushort *cidMap, int nCIDs,
107 GBool needVerticalMetrics,
108 FoFiOutputFunc outputFunc, void *outputStream);
110 // Convert to a Type 0 CIDFont, suitable for embedding in a
111 // PostScript file. <psName> will be used as the PostScript font
112 // name. (Only useful for OpenType CFF fonts.)
113 void convertToCIDType0(char *psName,
114 FoFiOutputFunc outputFunc, void *outputStream);
116 // Convert to a Type 0 (but non-CID) composite font, suitable for
117 // embedding in a PostScript file. <psName> will be used as the
118 // PostScript font name (so we don't need to depend on the 'name'
119 // table in the font). The <cidMap> array maps CIDs to GIDs; it has
120 // <nCIDs> entries. (Not useful for OpenType CFF fonts.)
121 void convertToType0(char *psName, Gushort *cidMap, int nCIDs,
122 GBool needVerticalMetrics,
123 FoFiOutputFunc outputFunc, void *outputStream);
125 // Convert to a Type 0 (but non-CID) composite font, suitable for
126 // embedding in a PostScript file. <psName> will be used as the
127 // PostScript font name. (Only useful for OpenType CFF fonts.)
128 void convertToType0(char *psName,
129 FoFiOutputFunc outputFunc, void *outputStream);
131 // Write a clean TTF file, filling in missing tables and correcting
132 // various other errors. If <name> is non-NULL, the font is renamed
133 // to <name>. If <codeToGID> is non-NULL, the font is re-encoded,
134 // using a Windows Unicode cmap. If <name> is NULL and the font is
135 // complete and correct, it will be written unmodified. (Not useful
136 // for OpenType CFF fonts.)
137 void writeTTF(FoFiOutputFunc outputFunc, void *outputStream,
138 char *name = NULL, Gushort *codeToGID = NULL);
140 private:
142 FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA);
143 void cvtEncoding(char **encoding,
144 FoFiOutputFunc outputFunc,
145 void *outputStream);
146 void cvtCharStrings(char **encoding,
147 Gushort *codeToGID,
148 FoFiOutputFunc outputFunc,
149 void *outputStream);
150 void cvtSfnts(FoFiOutputFunc outputFunc,
151 void *outputStream, GString *name,
152 GBool needVerticalMetrics);
153 void dumpString(Guchar *s, int length,
154 FoFiOutputFunc outputFunc,
155 void *outputStream);
156 Guint computeTableChecksum(Guchar *data, int length);
157 void parse();
158 void readPostTable();
159 int seekTable(char *tag);
161 TrueTypeTable *tables;
162 int nTables;
163 TrueTypeCmap *cmaps;
164 int nCmaps;
165 int nGlyphs;
166 int locaFmt;
167 int bbox[4];
168 GHash *nameToGID;
169 GBool openTypeCFF;
171 GBool parsedOk;
174 #endif