sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ftsnames.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftsnames.h
4 *
5 * Simple interface to access SFNT 'name' tables (which are used
6 * to hold font names, copyright info, notices, etc.) (specification).
7 *
8 * This is _not_ used to retrieve glyph names!
9 *
10 * Copyright (C) 1996-2025 by
11 * David Turner, Robert Wilhelm, and Werner Lemberg.
12 *
13 * This file is part of the FreeType project, and may only be used,
14 * modified, and distributed under the terms of the FreeType project
15 * license, LICENSE.TXT. By continuing to use, modify, or distribute
16 * this file you indicate that you have read the license and
17 * understand and accept it fully.
18 *
19 */
20
21
26#ifndef FTSNAMES_H_
27#define FTSNAMES_H_
28
29
30#include <freetype/freetype.h>
31#include <freetype/ftparams.h>
32
33#ifdef FREETYPE_H
34#error "freetype.h of FreeType 1 has been loaded!"
35#error "Please fix the directory search order for header files"
36#error "so that freetype.h of FreeType 2 is found first."
37#endif
38
39
40FT_BEGIN_HEADER
41
42
43 /**************************************************************************
44 *
45 * @section:
46 * sfnt_names
47 *
48 * @title:
49 * SFNT Names
50 *
51 * @abstract:
52 * Access the names embedded in TrueType and OpenType files.
53 *
54 * @description:
55 * The TrueType and OpenType specifications allow the inclusion of a
56 * special names table ('name') in font files. This table contains
57 * textual (and internationalized) information regarding the font, like
58 * family name, copyright, version, etc.
59 *
60 * The definitions below are used to access them if available.
61 *
62 * Note that this has nothing to do with glyph names!
63 *
64 */
65
66
67 /**************************************************************************
68 *
69 * @struct:
70 * FT_SfntName
71 *
72 * @description:
73 * A structure used to model an SFNT 'name' table entry.
74 *
75 * @fields:
76 * platform_id ::
77 * The platform ID for `string`. See @TT_PLATFORM_XXX for possible
78 * values.
79 *
80 * encoding_id ::
81 * The encoding ID for `string`. See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX,
82 * @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX for possible
83 * values.
84 *
85 * language_id ::
86 * The language ID for `string`. See @TT_MAC_LANGID_XXX and
87 * @TT_MS_LANGID_XXX for possible values.
88 *
89 * Registered OpenType values for `language_id` are always smaller than
90 * 0x8000; values equal or larger than 0x8000 usually indicate a
91 * language tag string (introduced in OpenType version 1.6). Use
92 * function @FT_Get_Sfnt_LangTag with `language_id` as its argument to
93 * retrieve the associated language tag.
94 *
95 * name_id ::
96 * An identifier for `string`. See @TT_NAME_ID_XXX for possible
97 * values.
98 *
99 * string ::
100 * The 'name' string. Note that its format differs depending on the
101 * (platform,encoding) pair, being either a string of bytes (without a
102 * terminating `NULL` byte) or containing UTF-16BE entities.
103 *
104 * string_len ::
105 * The length of `string` in bytes.
106 *
107 * @note:
108 * Please refer to the TrueType or OpenType specification for more
109 * details.
110 */
111 typedef struct FT_SfntName_
112 {
113 FT_UShort platform_id;
114 FT_UShort encoding_id;
115 FT_UShort language_id;
116 FT_UShort name_id;
117
118 FT_Byte* string; /* this string is *not* null-terminated! */
119 FT_UInt string_len; /* in bytes */
120
121 } FT_SfntName;
122
123
124 /**************************************************************************
125 *
126 * @function:
127 * FT_Get_Sfnt_Name_Count
128 *
129 * @description:
130 * Retrieve the number of name strings in the SFNT 'name' table.
131 *
132 * @input:
133 * face ::
134 * A handle to the source face.
135 *
136 * @return:
137 * The number of strings in the 'name' table.
138 *
139 * @note:
140 * This function always returns an error if the config macro
141 * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`.
142 */
143 FT_EXPORT( FT_UInt )
144 FT_Get_Sfnt_Name_Count( FT_Face face );
145
146
147 /**************************************************************************
148 *
149 * @function:
150 * FT_Get_Sfnt_Name
151 *
152 * @description:
153 * Retrieve a string of the SFNT 'name' table for a given index.
154 *
155 * @input:
156 * face ::
157 * A handle to the source face.
158 *
159 * idx ::
160 * The index of the 'name' string.
161 *
162 * @output:
163 * aname ::
164 * The indexed @FT_SfntName structure.
165 *
166 * @return:
167 * FreeType error code. 0~means success.
168 *
169 * @note:
170 * The `string` array returned in the `aname` structure is not
171 * null-terminated. Note that you don't have to deallocate `string` by
172 * yourself; FreeType takes care of it if you call @FT_Done_Face.
173 *
174 * Use @FT_Get_Sfnt_Name_Count to get the total number of available
175 * 'name' table entries, then do a loop until you get the right platform,
176 * encoding, and name ID.
177 *
178 * 'name' table format~1 entries can use language tags also, see
179 * @FT_Get_Sfnt_LangTag.
180 *
181 * This function always returns an error if the config macro
182 * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`.
183 */
184 FT_EXPORT( FT_Error )
185 FT_Get_Sfnt_Name( FT_Face face,
186 FT_UInt idx,
187 FT_SfntName *aname );
188
189
190 /**************************************************************************
191 *
192 * @struct:
193 * FT_SfntLangTag
194 *
195 * @description:
196 * A structure to model a language tag entry from an SFNT 'name' table.
197 *
198 * @fields:
199 * string ::
200 * The language tag string, encoded in UTF-16BE (without trailing
201 * `NULL` bytes).
202 *
203 * string_len ::
204 * The length of `string` in **bytes**.
205 *
206 * @note:
207 * Please refer to the TrueType or OpenType specification for more
208 * details.
209 *
210 * @since:
211 * 2.8
212 */
213 typedef struct FT_SfntLangTag_
214 {
215 FT_Byte* string; /* this string is *not* null-terminated! */
216 FT_UInt string_len; /* in bytes */
217
218 } FT_SfntLangTag;
219
220
221 /**************************************************************************
222 *
223 * @function:
224 * FT_Get_Sfnt_LangTag
225 *
226 * @description:
227 * Retrieve the language tag associated with a language ID of an SFNT
228 * 'name' table entry.
229 *
230 * @input:
231 * face ::
232 * A handle to the source face.
233 *
234 * langID ::
235 * The language ID, as returned by @FT_Get_Sfnt_Name. This is always a
236 * value larger than 0x8000.
237 *
238 * @output:
239 * alangTag ::
240 * The language tag associated with the 'name' table entry's language
241 * ID.
242 *
243 * @return:
244 * FreeType error code. 0~means success.
245 *
246 * @note:
247 * The `string` array returned in the `alangTag` structure is not
248 * null-terminated. Note that you don't have to deallocate `string` by
249 * yourself; FreeType takes care of it if you call @FT_Done_Face.
250 *
251 * Only 'name' table format~1 supports language tags. For format~0
252 * tables, this function always returns FT_Err_Invalid_Table. For
253 * invalid format~1 language ID values, FT_Err_Invalid_Argument is
254 * returned.
255 *
256 * This function always returns an error if the config macro
257 * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`.
258 *
259 * @since:
260 * 2.8
261 */
262 FT_EXPORT( FT_Error )
263 FT_Get_Sfnt_LangTag( FT_Face face,
264 FT_UInt langID,
265 FT_SfntLangTag *alangTag );
266
267
268 /* */
269
270
271FT_END_HEADER
272
273#endif /* FTSNAMES_H_ */
274
275
276/* END */