]> git.ipfire.org Git - thirdparty/cups.git/blame - pdftops/FoFiTrueType.h
Load cups into easysw/current.
[thirdparty/cups.git] / pdftops / FoFiTrueType.h
CommitLineData
ef416fc2 1//========================================================================
2//
3// FoFiTrueType.h
4//
5// Copyright 1999-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9#ifndef FOFITRUETYPE_H
10#define FOFITRUETYPE_H
11
12#include <config.h>
13
14#ifdef USE_GCC_PRAGMAS
15#pragma interface
16#endif
17
18#include "gtypes.h"
19#include "FoFiBase.h"
20
21class GString;
22class GHash;
23struct TrueTypeTable;
24struct TrueTypeCmap;
25
26//------------------------------------------------------------------------
27// FoFiTrueType
28//------------------------------------------------------------------------
29
30class FoFiTrueType: public FoFiBase {
31public:
32
33 // Create a FoFiTrueType object from a memory buffer.
34 static FoFiTrueType *make(char *fileA, int lenA);
35
36 // Create a FoFiTrueType object from a file on disk.
37 static FoFiTrueType *load(char *fileName);
38
39 virtual ~FoFiTrueType();
40
41 // Return the number of cmaps defined by this font.
42 int getNumCmaps();
43
44 // Return the platform ID of the <i>th cmap.
45 int getCmapPlatform(int i);
46
47 // Return the encoding ID of the <i>th cmap.
48 int getCmapEncoding(int i);
49
50 // Return the index of the cmap for <platform>, <encoding>. Returns
51 // -1 if there is no corresponding cmap.
52 int findCmap(int platform, int encoding);
53
54 // Return the GID corresponding to <c> according to the <i>th cmap.
55 Gushort mapCodeToGID(int i, int c);
56
57 // Returns the GID corresponding to <name> according to the post
58 // table. Returns 0 if there is no mapping for <name> or if the
59 // font does not have a post table.
60 int mapNameToGID(char *name);
61
62 // Returns the least restrictive embedding licensing right (as
63 // defined by the TrueType spec):
64 // * 4: OS/2 table is missing or invalid
65 // * 3: installable embedding
66 // * 2: editable embedding
67 // * 1: preview & print embedding
68 // * 0: restricted license embedding
69 int getEmbeddingRights();
70
71 // Convert to a Type 42 font, suitable for embedding in a PostScript
72 // file. <psName> will be used as the PostScript font name (so we
73 // don't need to depend on the 'name' table in the font). The
74 // <encoding> array specifies the mapping from char codes to names.
75 // If <encoding> is NULL, the encoding is unknown or undefined. The
76 // <codeToGID> array specifies the mapping from char codes to GIDs.
77 void convertToType42(char *psName, char **encoding,
78 Gushort *codeToGID,
79 FoFiOutputFunc outputFunc, void *outputStream);
80
81 // Convert to a Type 2 CIDFont, suitable for embedding in a
82 // PostScript file. <psName> will be used as the PostScript font
83 // name (so we don't need to depend on the 'name' table in the
84 // font). The <cidMap> array maps CIDs to GIDs; it has <nCIDs>
85 // entries.
86 void convertToCIDType2(char *psName, Gushort *cidMap, int nCIDs,
87 GBool needVerticalMetrics,
88 FoFiOutputFunc outputFunc, void *outputStream);
89
90 // Convert to a Type 0 (but non-CID) composite font, suitable for
91 // embedding in a PostScript file. <psName> will be used as the
92 // PostScript font name (so we don't need to depend on the 'name'
93 // table in the font). The <cidMap> array maps CIDs to GIDs; it has
94 // <nCIDs> entries.
95 void convertToType0(char *psName, Gushort *cidMap, int nCIDs,
96 GBool needVerticalMetrics,
97 FoFiOutputFunc outputFunc, void *outputStream);
98
99 // Write a clean TTF file, filling in missing tables and correcting
100 // various other errors. If <name> is non-NULL, the font is renamed
101 // to <name>. If <codeToGID> is non-NULL, the font is re-encoded,
102 // using a Windows Unicode cmap. If <name> is NULL and the font is
103 // complete and correct, it will be written unmodified.
104 void writeTTF(FoFiOutputFunc outputFunc, void *outputStream,
105 char *name = NULL, Gushort *codeToGID = NULL);
106
107private:
108
109 FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA);
110 void cvtEncoding(char **encoding,
111 FoFiOutputFunc outputFunc,
112 void *outputStream);
113 void cvtCharStrings(char **encoding,
114 Gushort *codeToGID,
115 FoFiOutputFunc outputFunc,
116 void *outputStream);
117 void cvtSfnts(FoFiOutputFunc outputFunc,
118 void *outputStream, GString *name,
119 GBool needVerticalMetrics);
120 void dumpString(Guchar *s, int length,
121 FoFiOutputFunc outputFunc,
122 void *outputStream);
123 Guint computeTableChecksum(Guchar *data, int length);
124 void parse();
125 void readPostTable();
126 int seekTable(char *tag);
127
128 TrueTypeTable *tables;
129 int nTables;
130 TrueTypeCmap *cmaps;
131 int nCmaps;
132 int nGlyphs;
133 int locaFmt;
134 int bbox[4];
135 GHash *nameToGID;
136
137 GBool parsedOk;
138};
139
140#endif