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

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 15 years ago

First import

File size: 4.6 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  FoFiTrueType(char *fileA, int lenA, GBool freeFileDataA, int faceIndexA=0);
38  virtual ~FoFiTrueType();
39
40  // Return the number of cmaps defined by this font.
41  int getNumCmaps();
42
43  // Return the platform ID of the <i>th cmap.
44  int getCmapPlatform(int i);
45
46  // Return the encoding ID of the <i>th cmap.
47  int getCmapEncoding(int i);
48
49  // Return the index of the cmap for <platform>, <encoding>.  Returns
50  // -1 if there is no corresponding cmap.
51  int findCmap(int platform, int encoding);
52
53  // Return the GID corresponding to <c> according to the <i>th cmap.
54  Gushort mapCodeToGID(int i, int c);
55
56  // Returns the GID corresponding to <name> according to the post
57  // table.  Returns 0 if there is no mapping for <name> or if the
58  // font does not have a post table.
59  int mapNameToGID(char *name);
60
61  // Returns the least restrictive embedding licensing right (as
62  // defined by the TrueType spec):
63  // * 4: OS/2 table is missing or invalid
64  // * 3: installable embedding
65  // * 2: editable embedding
66  // * 1: preview & print embedding
67  // * 0: restricted license embedding
68  int getEmbeddingRights();
69
70  // Convert to a Type 42 font, suitable for embedding in a PostScript
71  // file.  <psName> will be used as the PostScript font name (so we
72  // don't need to depend on the 'name' table in the font).  The
73  // <encoding> array specifies the mapping from char codes to names.
74  // If <encoding> is NULL, the encoding is unknown or undefined.  The
75  // <codeToGID> array specifies the mapping from char codes to GIDs.
76  void convertToType42(char *psName, char **encoding,
77                       Gushort *codeToGID,
78                       FoFiOutputFunc outputFunc, void *outputStream);
79
80  // Convert to a Type 2 CIDFont, suitable for embedding in a
81  // PostScript file.  <psName> will be used as the PostScript font
82  // name (so we don't need to depend on the 'name' table in the
83  // font).  The <cidMap> array maps CIDs to GIDs; it has <nCIDs>
84  // entries.
85  void convertToCIDType2(char *psName, Gushort *cidMap, int nCIDs,
86                         GBool needVerticalMetrics,
87                         FoFiOutputFunc outputFunc, void *outputStream);
88
89  // Convert to a Type 0 (but non-CID) composite font, suitable for
90  // embedding in a PostScript file.  <psName> will be used as the
91  // PostScript font name (so we don't need to depend on the 'name'
92  // table in the font).  The <cidMap> array maps CIDs to GIDs; it has
93  // <nCIDs> entries.
94  void convertToType0(char *psName, Gushort *cidMap, int nCIDs,
95                      GBool needVerticalMetrics,
96                      FoFiOutputFunc outputFunc, void *outputStream);
97
98  // Write a clean TTF file, filling in missing tables and correcting
99  // various other errors.  If <name> is non-NULL, the font is renamed
100  // to <name>.  If <codeToGID> is non-NULL, the font is re-encoded,
101  // using a Windows Unicode cmap.  If <name> is NULL and the font is
102  // complete and correct, it will be written unmodified.
103  void writeTTF(FoFiOutputFunc outputFunc, void *outputStream,
104                char *name = NULL, Gushort *codeToGID = NULL);
105
106private:
107
108  void cvtEncoding(char **encoding,
109                   FoFiOutputFunc outputFunc,
110                   void *outputStream);
111  void cvtCharStrings(char **encoding,
112                      Gushort *codeToGID,
113                      FoFiOutputFunc outputFunc,
114                      void *outputStream);
115  void cvtSfnts(FoFiOutputFunc outputFunc,
116                void *outputStream, GooString *name,
117                GBool needVerticalMetrics);
118  void dumpString(Guchar *s, int length,
119                  FoFiOutputFunc outputFunc,
120                  void *outputStream);
121  Guint computeTableChecksum(Guchar *data, int length);
122  void parse();
123  void readPostTable();
124  int seekTable(char *tag);
125
126  TrueTypeTable *tables;
127  int nTables;
128  TrueTypeCmap *cmaps;
129  int nCmaps;
130  int nGlyphs;
131  int locaFmt;
132  int bbox[4];
133  GooHash *nameToGID;
134
135  GBool parsedOk;
136  int faceIndex;
137};
138
139#endif
Note: See TracBrowser for help on using the repository browser.