1 /***************************************************************************/
5 /* Simple interface to access SFNT name tables (which are used */
6 /* to hold font names, copyright info, notices, etc.) (body). */
8 /* This is _not_ used to retrieve glyph names! */
10 /* Copyright 1996-2001, 2002, 2009 by */
11 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
19 /***************************************************************************/
23 #include FT_SFNT_NAMES_H
24 #include FT_INTERNAL_TRUETYPE_TYPES_H
25 #include FT_INTERNAL_STREAM_H
28 #ifdef TT_CONFIG_OPTION_SFNT_NAMES
31 /* documentation is in ftsnames.h */
33 FT_EXPORT_DEF( FT_UInt
)
34 FT_Get_Sfnt_Name_Count( FT_Face face
)
36 return ( face
&& FT_IS_SFNT( face
) ) ? ((TT_Face
)face
)->num_names
: 0;
40 /* documentation is in ftsnames.h */
42 FT_EXPORT_DEF( FT_Error
)
43 FT_Get_Sfnt_Name( FT_Face face
,
47 FT_Error error
= FT_Err_Invalid_Argument
;
50 if ( aname
&& face
&& FT_IS_SFNT( face
) )
52 TT_Face ttface
= (TT_Face
)face
;
55 if ( idx
< (FT_UInt
)ttface
->num_names
)
57 TT_NameEntryRec
* entry
= ttface
->name_table
.names
+ idx
;
60 /* load name on demand */
61 if ( entry
->stringLength
> 0 && entry
->string
== NULL
)
63 FT_Memory memory
= face
->memory
;
64 FT_Stream stream
= face
->stream
;
67 if ( FT_NEW_ARRAY ( entry
->string
, entry
->stringLength
) ||
68 FT_STREAM_SEEK( entry
->stringOffset
) ||
69 FT_STREAM_READ( entry
->string
, entry
->stringLength
) )
71 FT_FREE( entry
->string
);
72 entry
->stringLength
= 0;
76 aname
->platform_id
= entry
->platformID
;
77 aname
->encoding_id
= entry
->encodingID
;
78 aname
->language_id
= entry
->languageID
;
79 aname
->name_id
= entry
->nameID
;
80 aname
->string
= (FT_Byte
*)entry
->string
;
81 aname
->string_len
= entry
->stringLength
;
91 #endif /* TT_CONFIG_OPTION_SFNT_NAMES */