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

Last change on this file since 515 was 515, checked in by Silvan Scherrer, 9 years ago

updated poppler to 0.20.3

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