1 /***************************************************************************/
5 /* High-level SFNT driver interface (body). */
7 /* Copyright 1996-2001 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
20 #include FT_INTERNAL_SFNT_H
21 #include FT_INTERNAL_OBJECTS_H
28 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
32 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
36 #include <string.h> /* for strcmp() */
40 get_sfnt_table( TT_Face face,
49 table = &face->header;
53 table = &face->horizontal;
57 table = face->vertical_info ? &face->vertical : 0;
61 table = face->os2.version == 0xFFFF ? 0 : &face->os2;
65 table = &face->postscript;
69 table = &face->max_profile;
73 table = face->pclt.Version ? &face->pclt : 0;
84 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
88 get_sfnt_glyph_name( TT_Face face,
97 error = TT_Get_PS_Name( face, glyph_index, &gname );
98 if ( !error && buffer_max > 0 )
100 FT_UInt len = (FT_UInt)( strlen( gname ) );
103 if ( len >= buffer_max )
104 len = buffer_max - 1;
106 MEM_Copy( buffer, gname, len );
107 ((FT_Byte*)buffer)[len] = 0;
115 get_sfnt_postscript_name( TT_Face face )
119 /* shouldn't happen, but just in case to avoid memory leaks */
120 if ( face->root.internal->postscript_name )
121 return face->root.internal->postscript_name;
123 /* scan the name table to see if we have a Postscript name here, either */
124 /* in Macintosh or Windows platform encodings.. */
125 for ( n = 0; n < face->num_names; n++ )
127 TT_NameRec* name = face->name_table.names + n;
129 if ( name->nameID == 6 )
131 if ( ( name->platformID == 3 &&
132 name->encodingID == 1 &&
133 name->languageID == 0x409 ) ||
135 ( name->platformID == 1 &&
136 name->encodingID == 0 &&
137 name->languageID == 0 ) )
139 FT_UInt len = name->stringLength;
141 FT_Memory memory = face->root.memory;
144 if ( !ALLOC( result, len+1 ) )
146 memcpy( result, name->string, len );
149 face->root.internal->postscript_name = result;
160 #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
163 FT_CALLBACK_DEF( FT_Module_Interface )
164 SFNT_Get_Interface( FT_Module module,
165 const char* interface )
169 if ( strcmp( interface, "get_sfnt" ) == 0 )
170 return (FT_Module_Interface)get_sfnt_table;
172 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
173 if ( strcmp( interface, "glyph_name" ) == 0 )
174 return (FT_Module_Interface)get_sfnt_glyph_name;
177 if ( strcmp( interface, "postscript_name" ) == 0 )
178 return (FT_Module_Interface)get_sfnt_postscript_name;
185 const SFNT_Interface sfnt_interface =
199 TT_Load_Metrics_Header,
215 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
218 TT_Load_Bitmap_Header,
222 TT_Load_SBit_Strikes,
224 TT_Free_SBit_Strikes,
226 #else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
234 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
236 #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
242 #else /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
247 #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
255 FT_CALLBACK_TABLE_DEF
256 const FT_Module_Class sfnt_module_class =
258 0, /* not a font driver or renderer */
259 sizeof( FT_ModuleRec ),
261 "sfnt", /* driver name */
262 0x10000L, /* driver version 1.0 */
263 0x20000L, /* driver requires FreeType 2.0 or higher */
265 (const void*)&sfnt_interface, /* module specific interface */
267 (FT_Module_Constructor)0,
268 (FT_Module_Destructor) 0,
269 (FT_Module_Requester) SFNT_Get_Interface