1 //========================================================================
5 // Copyright 1999-2003 Glyph & Cog, LLC
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
16 // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
17 // Copyright (C) 2007 Koji Otani <sho@bbr.jp>
18 // Copyright (C) 2011, 2012 Albert Astals Cid <aacid@kde.org>
19 // Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
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
24 //========================================================================
26 #ifndef FOFITRUETYPE_H
27 #define FOFITRUETYPE_H
29 #ifdef USE_GCC_PRAGMAS
34 #include "goo/gtypes.h"
42 //------------------------------------------------------------------------
44 //------------------------------------------------------------------------
46 class FoFiTrueType
: public FoFiBase
{
49 // Create a FoFiTrueType object from a memory buffer.
50 static FoFiTrueType
*make(char *fileA
, int lenA
, int faceIndexA
=0);
52 // Create a FoFiTrueType object from a file on disk.
53 static FoFiTrueType
*load(char *fileName
, int faceIndexA
=0);
55 virtual ~FoFiTrueType();
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
; }
61 // Return the number of cmaps defined by this font.
64 // Return the platform ID of the <i>th cmap.
65 int getCmapPlatform(int i
);
67 // Return the encoding ID of the <i>th cmap.
68 int getCmapEncoding(int i
);
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
);
74 // Return the GID corresponding to <c> according to the <i>th cmap.
75 int mapCodeToGID(int i
, Guint c
);
77 // map gid to vertical glyph gid if exist.
78 // if not exist return original gid
79 Guint
mapToVertGID(Guint orgGID
);
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
);
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
);
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();
100 // Return the font matrix as an array of six numbers. (Only useful
101 // for OpenType CFF fonts.)
102 void getFontMatrix(double *mat
);
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
,
113 FoFiOutputFunc outputFunc
, void *outputStream
);
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
);
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
);
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
);
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
);
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
);
155 // Returns a pointer to the CFF font embedded in this OpenType font.
156 // If successful, sets *<start> and *<length>, and returns true.
157 // Otherwise returns false. (Only useful for OpenType CFF fonts).
158 GBool
getCFFBlock(char **start
, int *length
);
160 // setup vert/vrt2 GSUB for default lang
161 int setupGSUB(const char *scriptName
);
163 // setup vert/vrt2 GSUB for specified lang
164 int setupGSUB(const char *scriptName
, const char* languageName
);
168 FoFiTrueType(char *fileA
, int lenA
, GBool freeFileDataA
, int faceIndexA
);
169 void cvtEncoding(char **encoding
,
170 FoFiOutputFunc outputFunc
,
172 void cvtCharStrings(char **encoding
,
174 FoFiOutputFunc outputFunc
,
176 void cvtSfnts(FoFiOutputFunc outputFunc
,
177 void *outputStream
, GooString
*name
,
178 GBool needVerticalMetrics
,
180 void dumpString(Guchar
*s
, int length
,
181 FoFiOutputFunc outputFunc
,
183 Guint
computeTableChecksum(Guchar
*data
, int length
);
185 void readPostTable();
186 int seekTable(const char *tag
);
187 Guint
charToTag(const char *tagName
);
188 Guint
doMapToVertGID(Guint orgGID
);
189 Guint
scanLookupList(Guint listIndex
, Guint orgGID
);
190 Guint
scanLookupSubTable(Guint subTable
, Guint orgGID
);
191 int checkGIDInCoverage(Guint coverage
, Guint orgGID
);
193 TrueTypeTable
*tables
;
205 Guint gsubFeatureTable
;
206 Guint gsubLookupList
;