zenilib: zenilib/jni/external/freetype2/src/base/ftsnames.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 1996-2001, 2002, 2009 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
22 #include <ft2build.h>
23 #include FT_SFNT_NAMES_H
24 #include FT_INTERNAL_TRUETYPE_TYPES_H
25 #include FT_INTERNAL_STREAM_H
26
27
28 #ifdef TT_CONFIG_OPTION_SFNT_NAMES
29
30
31 /* documentation is in ftsnames.h */
32
33 FT_EXPORT_DEF( FT_UInt )
34 FT_Get_Sfnt_Name_Count( FT_Face face )
35 {
36 return ( face && FT_IS_SFNT( face ) ) ? ((TT_Face)face)->num_names : 0;
37 }
38
39
40 /* documentation is in ftsnames.h */
41
42 FT_EXPORT_DEF( FT_Error )
43 FT_Get_Sfnt_Name( FT_Face face,
44 FT_UInt idx,
45 FT_SfntName *aname )
46 {
47 FT_Error error = FT_Err_Invalid_Argument;
48
49
50 if ( aname && face && FT_IS_SFNT( face ) )
51 {
52 TT_Face ttface = (TT_Face)face;
53
54
55 if ( idx < (FT_UInt)ttface->num_names )
56 {
57 TT_NameEntryRec* entry = ttface->name_table.names + idx;
58
59
60 /* load name on demand */
61 if ( entry->stringLength > 0 && entry->string == NULL )
62 {
63 FT_Memory memory = face->memory;
64 FT_Stream stream = face->stream;
65
66
67 if ( FT_NEW_ARRAY ( entry->string, entry->stringLength ) ||
68 FT_STREAM_SEEK( entry->stringOffset ) ||
69 FT_STREAM_READ( entry->string, entry->stringLength ) )
70 {
71 FT_FREE( entry->string );
72 entry->stringLength = 0;
73 }
74 }
75
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;
82
83 error = FT_Err_Ok;
84 }
85 }
86
87 return error;
88 }
89
90
91 #endif /* TT_CONFIG_OPTION_SFNT_NAMES */
92
93
94 /* END */
FT_Error
int FT_Error
Definition: fttypes.h:296
NULL
#define NULL
Definition: ftobjs.h:61
FT_Err_Invalid_Argument
return FT_Err_Invalid_Argument
Definition: ftbbox.c:584
stream
GLuint GLuint stream
Definition: glew.h:6573
TT_NameEntryRec_::stringLength
FT_UShort stringLength
Definition: tttypes.h:207
FT_Err_Ok
return FT_Err_Ok
Definition: ftbbox.c:658
TT_NameEntryRec_::stringOffset
FT_ULong stringOffset
Definition: tttypes.h:208
TT_NameEntryRec_
Definition: tttypes.h:201
FT_Byte
unsigned char FT_Byte
Definition: fttypes.h:150
TT_NameEntryRec_::languageID
FT_UShort languageID
Definition: tttypes.h:205
FT_FREE
#define FT_FREE(ptr)
Definition: ftmemory.h:286
TT_Face
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:951
FT_FaceRec_
Definition: freetype.h:912
idx
FT_UInt idx
Definition: cffcmap.c:125
error
FT_Error error
Definition: cffdrivr.c:407
TT_FaceRec_::num_names
FT_UShort num_names
Definition: tttypes.h:1279
face
GLenum face
Definition: gl2ext.h:1490
FT_IS_SFNT
#define FT_IS_SFNT(face)
Definition: freetype.h:1160
TT_NameEntryRec_::platformID
FT_UShort platformID
Definition: tttypes.h:203
FT_Get_Sfnt_Name
FT_Get_Sfnt_Name(FT_Face face, FT_UInt idx, FT_SfntName *aname)
TT_NameTableRec_::names
TT_NameEntryRec * names
Definition: tttypes.h:243
FT_Memory
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
TT_FaceRec_::name_table
TT_NameTableRec name_table
Definition: tttypes.h:1280
FT_NEW_ARRAY
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:290
FT_STREAM_SEEK
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:496
FT_SfntName
FT_BEGIN_HEADER struct FT_SfntName_ FT_SfntName
ft2build.h
FT_EXPORT_DEF
#define FT_EXPORT_DEF(x)
Definition: ftconfig.h:511
FT_UInt
unsigned int FT_UInt
Definition: fttypes.h:227
TT_NameEntryRec_::encodingID
FT_UShort encodingID
Definition: tttypes.h:204
FT_Get_Sfnt_Name_Count
FT_Get_Sfnt_Name_Count(FT_Face face)
FT_StreamRec_
Definition: ftsystem.h:321
TT_FaceRec_
Definition: tttypes.h:1258
FT_STREAM_READ
#define FT_STREAM_READ(buffer, count)
Definition: ftstream.h:502
TT_NameEntryRec_::nameID
FT_UShort nameID
Definition: tttypes.h:206
TT_NameEntryRec_::string
FT_Byte * string
Definition: tttypes.h:213