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

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

PDF plugin: Poppler library updated to version 0.10.0

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