source: trunk/poppler/mypoppler/fofi/FoFiTrueType.h @ 250

Last change on this file since 250 was 250, checked in by Eugene Romanenko, 13 years ago

PDF plugin: poppler library updated to version 0.8.3

File size: 6.7 KB
Line 
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#ifdef USE_GCC_PRAGMAS
13#pragma interface
14#endif
15
16#include "goo/gtypes.h"
17#include "FoFiBase.h"
18
19class GooString;
20class GooHash;
21struct TrueTypeTable;
22struct TrueTypeCmap;
23
24//------------------------------------------------------------------------
25// FoFiTrueType
26//------------------------------------------------------------------------
27
28class FoFiTrueType: public FoFiBase {
29public:
30
31  // Create a FoFiTrueType object from a memory buffer.
32  static FoFiTrueType *make(char *fileA, int lenA, int faceIndexA=0);
33
34  // Create a FoFiTrueType object from a file on disk.
35  static FoFiTrueType *load(char *fileName, int faceIndexA=0);
36
37  virtual ~FoFiTrueType();
38
39  // Returns true if this an OpenType font containing CFF data, false
40  // if it's a TrueType font (or OpenType font with TrueType data).
41  GBool isOpenTypeCFF() { return openTypeCFF; }
42
43  // Return the number of cmaps defined by this font.
44  int getNumCmaps();
45
46  // Return the platform ID of the <i>th cmap.
47  int getCmapPlatform(int i);
48
49  // Return the encoding ID of the <i>th cmap.
50  int getCmapEncoding(int i);
51
52  // Return the index of the cmap for <platform>, <encoding>.  Returns
53  // -1 if there is no corresponding cmap.
54  int findCmap(int platform, int encoding);
55
56  // Return the GID corresponding to <c> according to the <i>th cmap.
57  Gushort mapCodeToGID(int i, Guint c);
58
59  // map gid to vertical glyph gid if exist.
60  //   if not exist return original gid
61  Guint mapToVertGID(Guint orgGID);
62
63  // Returns the GID corresponding to <name> according to the post
64  // table.  Returns 0 if there is no mapping for <name> or if the
65  // font does not have a post table.
66  int mapNameToGID(char *name);
67
68  // Return the mapping from CIDs to GIDs, and return the number of
69  // CIDs in *<nCIDs>.  This is only useful for CID fonts.  (Only
70  // useful for OpenType CFF fonts.)
71  Gushort *getCIDToGIDMap(int *nCIDs);
72
73  // Returns the least restrictive embedding licensing right (as
74  // defined by the TrueType spec):
75  // * 4: OS/2 table is missing or invalid
76  // * 3: installable embedding
77  // * 2: editable embedding
78  // * 1: preview & print embedding
79  // * 0: restricted license embedding
80  int getEmbeddingRights();
81
82  // Convert to a Type 42 font, suitable for embedding in a PostScript
83  // file.  <psName> will be used as the PostScript font name (so we
84  // don't need to depend on the 'name' table in the font).  The
85  // <encoding> array specifies the mapping from char codes to names.
86  // If <encoding> is NULL, the encoding is unknown or undefined.  The
87  // <codeToGID> array specifies the mapping from char codes to GIDs.
88  // (Not useful for OpenType CFF fonts.)
89  void convertToType42(char *psName, char **encoding,
90                       Gushort *codeToGID,
91                       FoFiOutputFunc outputFunc, void *outputStream);
92
93  // Convert to a Type 1 font, suitable for embedding in a PostScript
94  // file.  This is only useful with 8-bit fonts.  If <newEncoding> is
95  // not NULL, it will be used in place of the encoding in the Type 1C
96  // font.  If <ascii> is true the eexec section will be hex-encoded,
97  // otherwise it will be left as binary data.  If <psName> is
98  // non-NULL, it will be used as the PostScript font name.  (Only
99  // useful for OpenType CFF fonts.)
100  void convertToType1(char *psName, char **newEncoding, GBool ascii,
101                      FoFiOutputFunc outputFunc, void *outputStream);
102
103  // Convert to a Type 2 CIDFont, suitable for embedding in a
104  // PostScript file.  <psName> will be used as the PostScript font
105  // name (so we don't need to depend on the 'name' table in the
106  // font).  The <cidMap> array maps CIDs to GIDs; it has <nCIDs>
107  // entries.  (Not useful for OpenType CFF fonts.)
108  void convertToCIDType2(char *psName, Gushort *cidMap, int nCIDs,
109                         GBool needVerticalMetrics,
110                         FoFiOutputFunc outputFunc, void *outputStream);
111
112  // Convert to a Type 0 CIDFont, suitable for embedding in a
113  // PostScript file.  <psName> will be used as the PostScript font
114  // name.  (Only useful for OpenType CFF fonts.)
115  void convertToCIDType0(char *psName,
116                         FoFiOutputFunc outputFunc, void *outputStream);
117
118  // Convert to a Type 0 (but non-CID) composite font, suitable for
119  // embedding in a PostScript file.  <psName> will be used as the
120  // PostScript font name (so we don't need to depend on the 'name'
121  // table in the font).  The <cidMap> array maps CIDs to GIDs; it has
122  // <nCIDs> entries.  (Not useful for OpenType CFF fonts.)
123  void convertToType0(char *psName, Gushort *cidMap, int nCIDs,
124                      GBool needVerticalMetrics,
125                      FoFiOutputFunc outputFunc, void *outputStream);
126
127  // Convert to a Type 0 (but non-CID) composite font, suitable for
128  // embedding in a PostScript file.  <psName> will be used as the
129  // PostScript font name.  (Only useful for OpenType CFF fonts.)
130  void convertToType0(char *psName,
131                      FoFiOutputFunc outputFunc, void *outputStream);
132
133  // Write a clean TTF file, filling in missing tables and correcting
134  // various other errors.  If <name> is non-NULL, the font is renamed
135  // to <name>.  If <codeToGID> is non-NULL, the font is re-encoded,
136  // using a Windows Unicode cmap.  If <name> is NULL and the font is
137  // complete and correct, it will be written unmodified.  (Not useful
138  // for OpenType CFF fonts.)
139  void writeTTF(FoFiOutputFunc outputFunc, void *outputStream,
140                char *name = NULL, Gushort *codeToGID = NULL);
141
142  int setupGSUB(const char *tagName);
143private:
144
145  FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA);
146  void cvtEncoding(char **encoding,
147                   FoFiOutputFunc outputFunc,
148                   void *outputStream);
149  void cvtCharStrings(char **encoding,
150                      Gushort *codeToGID,
151                      FoFiOutputFunc outputFunc,
152                      void *outputStream);
153  void cvtSfnts(FoFiOutputFunc outputFunc,
154                void *outputStream, GooString *name,
155                GBool needVerticalMetrics);
156  void dumpString(Guchar *s, int length,
157                  FoFiOutputFunc outputFunc,
158                  void *outputStream);
159  Guint computeTableChecksum(Guchar *data, int length);
160  void parse();
161  void readPostTable();
162  int seekTable(char *tag);
163  Guint charToTag(const char *tagName);
164  Guint doMapToVertGID(Guint orgGID);
165  Guint scanLookupList(Guint listIndex, Guint orgGID);
166  Guint scanLookupSubTable(Guint subTable, Guint orgGID);
167  int checkGIDInCoverage(Guint coverage, Guint orgGID);
168
169  TrueTypeTable *tables;
170  int nTables;
171  TrueTypeCmap *cmaps;
172  int nCmaps;
173  int nGlyphs;
174  int locaFmt;
175  int bbox[4];
176  GooHash *nameToGID;
177  GBool openTypeCFF;
178
179  GBool parsedOk;
180  int faceIndex;
181  Guint gsubFeatureTable;
182  Guint gsubLookupList;
183};
184
185#endif
Note: See TracBrowser for help on using the repository browser.