Debian Codegraph @

podofo/3rdparty/adobe/afdko/resource/nameread.h

raw
1 /* Copyright 2016 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved.
2 This software is licensed as OpenSource, under the Apache License, Version 2.0.
3 This license is available at: http://opensource.org/licenses/Apache-2.0. */
4
5 #ifndef NAMEREAD_H
6 #define NAMEREAD_H
7
8 #include "ctlshare.h"
9 #include "sfntread.h"
10 #include "varread.h"
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 /* Name Table Reader Library
17 =======================================
18 This library reads the name table.
19 */
20
21 /* constants/types */
22
23 typedef struct /* name record */
24 {
25 unsigned short platformId;
26 unsigned short platspecId;
27 unsigned short languageId;
28 unsigned short nameId;
29 unsigned short length;
30 unsigned long offset;
31 } nam_NameRecord;
32
33 struct nam_name_; /* name table */
34 typedef struct nam_name_ *nam_name;
35
36 /* name and cmap table platform and platform-specific ids */
37 enum {
38 /* Platform ids */
39 NAME_UNI_PLATFORM = 0, /* Unicode */
40 NAME_MAC_PLATFORM = 1, /* Macintosh */
41 NAME_WIN_PLATFORM = 3, /* Microsoft */
42
43 /* Unicode platform-specific ids */
44 NAME_UNI_DEFAULT = 0, /* Default semantics */
45 NAME_UNI_VER_1_1 = 1, /* Version 1.1 semantics */
46 NAME_UNI_ISO_10646 = 2, /* ISO 10646 semantics */
47 NAME_UNI_VER_2_0 = 3, /* Version 2.0 semantics */
48
49 /* Macintosh platform-specific and language ids */
50 NAME_MAC_ROMAN = 0, /* Roman */
51 NAME_MAC_ENGLISH = 0, /* English language */
52
53 /* Windows platform-specific and language ids */
54 NAME_WIN_SYMBOL = 0, /* Undefined index scheme */
55 NAME_WIN_UGL = 1, /* UGL */
56 NAME_WIN_ENGLISH = 0x409 /* English (American) language */
57 };
58
59 /* name IDs */
60 enum {
61 NAME_ID_COPYRIGHT = 0, /* copyright notice */
62 NAME_ID_FAMILY = 1, /* family name */
63 NAME_ID_SUBFAMILY = 2, /* sub-family name */
64 NAME_ID_UNIQUEID = 3, /* unique font identifier */
65 NAME_ID_FULL = 4, /* full name */
66 NAME_ID_VERSION = 5, /* version */
67 NAME_ID_POSTSCRIPT = 6, /* Postscript font name */
68 NAME_ID_TRADEMARK = 7, /* trademark */
69 NAME_ID_TYPO_FAMILY = 16, /* typographic family name */
70 NAME_ID_CIDFONTNAME = 20, /* CID font name */
71 NAME_ID_POSTSCRIPT_PREFIX = 25 /* Postscript font name prefix */
72 };
73
74 /* functions */
75 nam_name nam_loadname(sfrCtx sfr, ctlSharedStmCallbacks *sscb);
76
77 /* nam_loadname() loads the name table from an SFNT font.
78 If not found, NULL is returned.
79
80 sfr - context pointer created by calling sfrNew in sfntread library.
81
82 sscb - a pointer to shared stream callback functions.
83 */
84
85 void nam_freename(ctlSharedStmCallbacks *sscb, nam_name tbl);
86
87 /* nam_freename() frees the name table loaded by calling nam_loadname().
88
89 sscb - a pointer to shared stream callback functions.
90
91 tbl - a pointer to the name table to be freed.
92 */
93
94 nam_NameRecord *nam_nameFind(nam_name tbl,
95 unsigned short platformId,
96 unsigned short platspecId,
97 unsigned short languageId,
98 unsigned short nameId);
99
100 /* nam_nameFind() looks up the name table for a name record.
101 A pointer to a found name record is returned.
102 If not found, NULL is returned.
103
104 tbl - name table data loaded by calling nam_loadname in nameread library.
105
106 platformId - the platform ID of the name record to be returned.
107
108 platspecId - the platform specific ID of the name record to be returned.
109
110 languageId - the language ID of the name record to be returned.
111
112 nameId - the name ID in the name table to be retrieved.
113 */
114
115 enum {
116 NAME_READ_FAILED = 0,
117 NAME_READ_NAME_NOT_FOUND = -1,
118 NAME_READ_NAME_TOO_LONG = -2
119 };
120
121 long nam_getASCIIName(nam_name tbl,
122 ctlSharedStmCallbacks *sscb,
123 char *buffer, unsigned long bufferLen,
124 unsigned short nameId,
125 int isPS);
126
127 /* nam_getASCIIName() looks up the name table for an ASCII name string specified by a name ID.
128 If a name string contains any Unicode characters outside of the ASCII range,
129 they are removed from the result.
130
131 The length of the name is returned as the result.
132 If no name is found, NAME_READ_NAME_NOT_FOUND is returned.
133 If a found name exceeds the given buffer length, NAME_READ_NAME_TOO_LONG is returned.
134
135 tbl - name table data loaded by calling nam_loadname in nameread library.
136
137 sscb - pointer to shared stream callback functions.
138
139 buffer - where a name is returned.
140
141 bufferLen - the allocated byte length of buffer. Note that a null character
142 is added at the end of the name string, so the actual length of the name will be at most
143 bufferLen-1.
144
145 nameId - the name ID in the name table to be looked up.
146
147 isPS - if non-zero, the returned name must be Postscript-safe
148 */
149
150 long nam_getFamilyNamePrefix(nam_name nameTbl,
151 ctlSharedStmCallbacks *sscb,
152 char *buffer, unsigned long bufferLen);
153 /* nam_getFamilyNamePrefix() returns a font name prefix string to be used
154 to name a CFF2 variable font instance.
155 The length of the name is returned as the result.
156 If no name is found, NAME_READ_INST_NOT_FOUND is returned.
157 If a found name exceeds the given buffer length, NAME_READ_NAME_TOO_LONG is returned.
158
159 nameTbl - name table data loaded by calling nam_loadname in nameread library.
160
161 sscb - pointer to shared stream callback functions.
162
163 coords - the user design vector. May be NULL if the default instance or a named
164 instance is specified.
165
166 buffer - where a font name prefix string is returned.
167
168 bufferLen - the allocated byte length of buffer. Note that a null character
169 is added at the end of the name string, so the actual length of the name will be at most
170 bufferLen-1. */
171
172 long nam_getNamedInstancePSName(nam_name nameTbl,
173 var_axes axesTbl,
174 ctlSharedStmCallbacks *sscb,
175 float *coords,
176 unsigned short axisCount,
177 int instanceIndex,
178 char *instanceName, unsigned long instanceNameLen);
179
180 /* nam_getNamedInstancePSName() looks up the fvar table for a named instance of a CFF2 variable font
181 specified either by its instance index or a design vector of the instance.
182 The length of the name is returned as the result.
183 If no name is found, NAME_READ_INST_NOT_FOUND is returned.
184 If a found name exceeds the given buffer length, NAME_READ_NAME_TOO_LONG is returned.
185
186 nameTbl - name table data loaded by calling nam_loadname in nameread library.
187
188 axesTbl - axes table data loaded by calling var_loadaxes in varread library.
189
190 sscb - pointer to shared stream callback functions.
191
192 coords - the user design vector. May be NULL if the default instance or a named
193 instance is specified.
194
195 axisCount - the number of axes in the variable font.
196
197 instanceIndex - specifies the named instance. If -1, coords specifies an
198 arbitrary instance.
199
200 instanceName - where a generated PostScript name of the instance is returned.
201
202 instanceNameLen - the allocated byte length of instanceName. Note that a null character
203 is added at the end of the name string, so the actual length of the name will be at most
204 instanceNameLen-1. */
205
206 long nam_generateArbitraryInstancePSName(nam_name nameTbl,
207 var_axes axesTbl,
208 ctlSharedStmCallbacks *sscb,
209 float *coords,
210 unsigned short axisCount,
211 char *instanceName, unsigned long instanceNameLen);
212
213 /* nam_generateArbitraryInstancePSName() generate a PS name of an arbitrary instance
214 of a CFF2 variable font specified by a design vector of the instance.
215 The length of the name is returned as the result.
216 If no name is found, NAME_READ_INST_NOT_FOUND is returned.
217 If a found name exceeds the given buffer length, NAME_READ_NAME_TOO_LONG is returned.
218
219 nameTbl - name table data loaded by calling nam_loadname in nameread library.
220
221 axesTbl - axes table data loaded by calling var_loadaxes in varread library.
222
223 sscb - pointer to shared stream callback functions.
224
225 coords - the user design vector.
226
227 axisCount - the number of axes in the variable font.
228
229 instanceName - where a generated PostScript name of the instance is returned.
230
231 instanceNameLen - the allocated byte length of instanceName. Note that a null character
232 is added at the end of the name string, so the actual length of the name will be at most
233 instanceNameLen-1. */
234
235 long nam_generateLastResortInstancePSName(nam_name nameTbl,
236 var_axes axesTbl,
237 ctlSharedStmCallbacks *sscb,
238 float *coords,
239 unsigned short axisCount,
240 char *instanceName, unsigned long instanceNameLen);
241
242 /* nam_generateLastResortInstancePSName() generates a unique PostScript font name
243 for the specified instance of a CFF2 variable font by hashing the coordinate values
244 as the last resort.
245 The length of the name is returned as the result.
246 If no name is found, NAME_READ_INST_NOT_FOUND is returned.
247 If a name exceeds the given buffer length, NAME_READ_NAME_TOO_LONG is returned.
248
249 nameTbl - name table data loaded by calling nam_loadname in nameread library.
250
251 axesTbl - axes table data loaded by calling var_loadaxes in varread library.
252
253 sscb - pointer to shared stream callback functions.
254
255 coords - the user design vector. May be NULL if the default instance or a named
256 instance is specified.
257
258 axisCount - the number of axes in the variable font.
259
260 instanceName - where a generated PostScript name of the instance is returned.
261
262 instanceNameLen - the allocated byte length of instanceName. Note that a null character
263 is added at the end of the name string, so the actual length of the name will be at most
264 instanceNameLen-1. */
265
266 #ifdef __cplusplus
267 }
268 #endif
269
270 #endif /* NAMEREAD_H */