ReactOS 0.4.16-dev-2354-g16de117
ftsnames.c
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftsnames.c
4 *
5 * Simple interface to access SFNT name tables (which are used
6 * to hold font names, copyright info, notices, etc.) (body).
7 *
8 * This is _not_ used to retrieve glyph names!
9 *
10 * Copyright (C) 1996-2020 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
23
24#include <freetype/ftsnames.h>
27
28
29#ifdef TT_CONFIG_OPTION_SFNT_NAMES
30
31
32 /* documentation is in ftsnames.h */
33
36 {
37 return ( face && FT_IS_SFNT( face ) ) ? ((TT_Face)face)->num_names : 0;
38 }
39
40
41 /* documentation is in ftsnames.h */
42
46 FT_SfntName *aname )
47 {
48 FT_Error error = FT_ERR( Invalid_Argument );
49
50
51 if ( aname && face && FT_IS_SFNT( face ) )
52 {
53 TT_Face ttface = (TT_Face)face;
54
55
56 if ( idx < (FT_UInt)ttface->num_names )
57 {
58 TT_Name entry = ttface->name_table.names + idx;
59
60
61 /* load name on demand */
62 if ( entry->stringLength > 0 && !entry->string )
63 {
64 FT_Memory memory = face->memory;
65 FT_Stream stream = face->stream;
66
67
68 if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) ||
69 FT_STREAM_SEEK( entry->stringOffset ) ||
70 FT_STREAM_READ( entry->string, entry->stringLength ) )
71 {
72 FT_FREE( entry->string );
73 entry->stringLength = 0;
74 }
75 }
76
77 aname->platform_id = entry->platformID;
78 aname->encoding_id = entry->encodingID;
79 aname->language_id = entry->languageID;
80 aname->name_id = entry->nameID;
81 aname->string = (FT_Byte*)entry->string;
82 aname->string_len = entry->stringLength;
83
85 }
86 }
87
88 return error;
89 }
90
91
92 /* documentation is in ftsnames.h */
93
96 FT_UInt langID,
97 FT_SfntLangTag *alangTag )
98 {
99 FT_Error error = FT_ERR( Invalid_Argument );
100
101
102 if ( alangTag && face && FT_IS_SFNT( face ) )
103 {
104 TT_Face ttface = (TT_Face)face;
105
106
107 if ( ttface->name_table.format != 1 )
108 return FT_THROW( Invalid_Table );
109
110 if ( langID > 0x8000U &&
111 langID - 0x8000U < ttface->name_table.numLangTagRecords )
112 {
114 ( langID - 0x8000U );
115
116
117 /* load name on demand */
118 if ( entry->stringLength > 0 && !entry->string )
119 {
120 FT_Memory memory = face->memory;
121 FT_Stream stream = face->stream;
122
123
124 if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) ||
125 FT_STREAM_SEEK( entry->stringOffset ) ||
126 FT_STREAM_READ( entry->string, entry->stringLength ) )
127 {
128 FT_FREE( entry->string );
129 entry->stringLength = 0;
130 }
131 }
132
133 alangTag->string = (FT_Byte*)entry->string;
134 alangTag->string_len = entry->stringLength;
135
137 }
138 }
139
140 return error;
141 }
142
143
144#else /* !TT_CONFIG_OPTION_SFNT_NAMES */
145
146
149 {
150 FT_UNUSED( face );
151
152 return 0;
153 }
154
155
158 FT_UInt idx,
159 FT_SfntName *aname )
160 {
161 FT_UNUSED( face );
162 FT_UNUSED( idx );
163 FT_UNUSED( aname );
164
165 return FT_THROW( Unimplemented_Feature );
166 }
167
168
171 FT_UInt langID,
172 FT_SfntLangTag *alangTag )
173 {
174 FT_UNUSED( face );
175 FT_UNUSED( langID );
176 FT_UNUSED( alangTag );
177
178 return FT_THROW( Unimplemented_Feature );
179 }
180
181
182#endif /* !TT_CONFIG_OPTION_SFNT_NAMES */
183
184
185/* END */
#define FT_EXPORT_DEF(x)
unsigned int idx
Definition: utils.c:41
#define FT_IS_SFNT(face)
Definition: freetype.h:1290
return FT_Err_Ok
Definition: ftbbox.c:526
#define FT_THROW(e)
Definition: ftdebug.h:243
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:341
#define FT_FREE(ptr)
Definition: ftmemory.h:337
FT_Get_Sfnt_Name_Count(FT_Face face)
Definition: ftsnames.c:148
FT_Get_Sfnt_Name(FT_Face face, FT_UInt idx, FT_SfntName *aname)
Definition: ftsnames.c:157
FT_Get_Sfnt_LangTag(FT_Face face, FT_UInt langID, FT_SfntLangTag *alangTag)
Definition: ftsnames.c:170
FT_BEGIN_HEADER struct FT_SfntName_ FT_SfntName
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:525
#define FT_STREAM_READ(buffer, count)
Definition: ftstream.h:533
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:64
unsigned char FT_Byte
Definition: fttypes.h:154
int FT_Error
Definition: fttypes.h:299
#define FT_ERR(e)
Definition: fttypes.h:599
unsigned int FT_UInt
Definition: fttypes.h:231
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
uint32_t entry
Definition: isohybrid.c:63
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:122
#define FT_UNUSED(arg)
FT_Byte * string
Definition: ftsnames.h:211
FT_UInt string_len
Definition: ftsnames.h:212
TT_NameTableRec name_table
Definition: tttypes.h:1481
FT_UShort num_names
Definition: tttypes.h:1480
TT_NameRec * names
Definition: tttypes.h:306
TT_LangTagRec * langTags
Definition: tttypes.h:308
FT_UInt numLangTagRecords
Definition: tttypes.h:307
FT_UShort format
Definition: tttypes.h:303
Definition: parse.h:23
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:988