implementing a new function named "FT_Get_Postscript_Name" to
retrieve a face's "unique" Postscript name
This commit is contained in:
parent
40d006af7c
commit
23bcde193e
@ -1,7 +1,11 @@
|
||||
2001-10-17 David Turner >david@freetype.org>
|
||||
|
||||
Tagging files with VER-2-0-5 for upcoming 2.0.5 release
|
||||
Testing new CVS-mail script (thanks Just !)
|
||||
* include/freetype/freetype.h, include/internal/ftobjs.h,
|
||||
src/base/ftobjs.c, src/sfnt/sfdriver.c, type1/t1driver.c,
|
||||
cid/cidriver.c: Adding a new function named 'FT_Get_Postscript_Name' to
|
||||
retrieve the Postscript name of a given font. Should work with all
|
||||
formats except pure CFF/CEF fonts (this will be added soon).
|
||||
|
||||
|
||||
2001-10-08 David Turner <david@freetype.org>
|
||||
|
||||
|
@ -2286,6 +2286,30 @@ FT_BEGIN_HEADER
|
||||
FT_UInt buffer_max );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Postscript_Name */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieves the ASCII Postscript name of a given face, when */
|
||||
/* available. This should only work with Postscript and TrueType */
|
||||
/* fonts.. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: handle to source face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* pointer to face's Postscript name. NULL when un-available */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The returned pointer is owned by the face and will be destroyed */
|
||||
/* with it. */
|
||||
/* */
|
||||
FT_EXPORT( const char* )
|
||||
FT_Get_Postscript_Name( FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
|
@ -129,14 +129,18 @@ FT_BEGIN_HEADER
|
||||
/* transform_flags :: Some flags used to classify the transform. */
|
||||
/* Only used by the convenience functions. */
|
||||
/* */
|
||||
/* postscript_name :: Postscript font name for this face. */
|
||||
/* */
|
||||
typedef struct FT_Face_InternalRec_
|
||||
{
|
||||
FT_UShort max_points;
|
||||
FT_Short max_contours;
|
||||
FT_UShort max_points;
|
||||
FT_Short max_contours;
|
||||
|
||||
FT_Matrix transform_matrix;
|
||||
FT_Vector transform_delta;
|
||||
FT_Int transform_flags;
|
||||
FT_Matrix transform_matrix;
|
||||
FT_Vector transform_delta;
|
||||
FT_Int transform_flags;
|
||||
|
||||
const char* postscript_name;
|
||||
|
||||
} FT_Face_InternalRec;
|
||||
|
||||
@ -628,6 +632,9 @@ FT_BEGIN_HEADER
|
||||
FT_GlyphSlot slot,
|
||||
FT_UInt render_mode );
|
||||
|
||||
typedef const char*
|
||||
(*FT_PSName_Requester)( FT_Face face );
|
||||
|
||||
typedef FT_Error
|
||||
(*FT_Glyph_Name_Requester)( FT_Face face,
|
||||
FT_UInt glyph_index,
|
||||
|
@ -1011,8 +1011,8 @@
|
||||
if ( face->autohint.finalizer )
|
||||
face->autohint.finalizer( face->autohint.data );
|
||||
|
||||
/* Discard glyph slots for this face */
|
||||
/* Beware! FT_Done_GlyphSlot() changes the field `face->slot' */
|
||||
/* Discard glyph slots for this face */
|
||||
/* Beware! FT_Done_GlyphSlot() changes the field `face->glyph' */
|
||||
while ( face->glyph )
|
||||
FT_Done_GlyphSlot( face->glyph );
|
||||
|
||||
@ -1037,7 +1037,11 @@
|
||||
( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );
|
||||
|
||||
/* get rid of it */
|
||||
FREE( face->internal );
|
||||
if ( face->internal )
|
||||
{
|
||||
FREE( face->internal->postscript_name );
|
||||
FREE( face->internal );
|
||||
}
|
||||
FREE( face );
|
||||
}
|
||||
|
||||
@ -1906,6 +1910,38 @@
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in freetype.h */
|
||||
|
||||
FT_EXPORT_DEF( const char* )
|
||||
FT_Get_Postscript_Name( FT_Face face )
|
||||
{
|
||||
const char* result = NULL;
|
||||
|
||||
if ( !face )
|
||||
goto Exit;
|
||||
|
||||
result = face->internal->postscript_name;
|
||||
if ( !result )
|
||||
{
|
||||
/* now, lookup for glyph name */
|
||||
FT_Driver driver = face->driver;
|
||||
FT_Module_Class* clazz = FT_MODULE_CLASS( driver );
|
||||
|
||||
if ( clazz->get_interface )
|
||||
{
|
||||
FT_PSName_Requester requester;
|
||||
|
||||
requester = (FT_PSName_Requester)clazz->get_interface(
|
||||
FT_MODULE( driver ), "postscript_name" );
|
||||
if ( requester )
|
||||
result = requester( face );
|
||||
}
|
||||
}
|
||||
Exit:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* documentation is in tttables.h */
|
||||
|
||||
FT_EXPORT_DEF( void* )
|
||||
|
@ -38,6 +38,14 @@
|
||||
#define FT_COMPONENT trace_ciddriver
|
||||
|
||||
|
||||
|
||||
static const char*
|
||||
cid_get_postscript_name( CID_Face face )
|
||||
{
|
||||
return (const char*)face->cid.cid_font_name;
|
||||
}
|
||||
|
||||
|
||||
static FT_Module_Interface
|
||||
CID_Get_Interface( FT_Driver driver,
|
||||
const FT_String* interface )
|
||||
@ -45,6 +53,9 @@
|
||||
FT_UNUSED( driver );
|
||||
FT_UNUSED( interface );
|
||||
|
||||
if ( strcmp( (const char*)interface, "postscript_name" ) == 0 )
|
||||
return (FT_Module_Interface)cid_get_postscript_name;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -174,6 +185,7 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
FT_CALLBACK_TABLE_DEF
|
||||
const FT_Driver_Class t1cid_driver_class =
|
||||
{
|
||||
|
@ -111,6 +111,52 @@
|
||||
}
|
||||
|
||||
|
||||
static const char*
|
||||
get_sfnt_postscript_name( TT_Face face )
|
||||
{
|
||||
FT_Int n;
|
||||
|
||||
/* shouldn't happen, but just in case to avoid memory leaks */
|
||||
if ( face->root.internal->postscript_name )
|
||||
return face->root.internal->postscript_name;
|
||||
|
||||
/* scan the name table to see if we have a Postscript name here, either */
|
||||
/* in Macintosh or Windows platform encodings.. */
|
||||
for ( n = 0; n < face->num_names; n++ )
|
||||
{
|
||||
TT_NameRec* name = face->name_table.names + n;
|
||||
|
||||
if ( name->nameID == 6 )
|
||||
{
|
||||
if ( ( name->platformID == 3 &&
|
||||
name->encodingID == 1 &&
|
||||
name->languageID == 0x409 ) ||
|
||||
|
||||
( name->platformID == 1 &&
|
||||
name->encodingID == 0 &&
|
||||
name->languageID == 0 ) )
|
||||
{
|
||||
FT_UInt len = name->stringLength;
|
||||
FT_Error error;
|
||||
FT_Memory memory = face->root.memory;
|
||||
FT_String* result;
|
||||
|
||||
if ( !ALLOC( result, len+1 ) )
|
||||
{
|
||||
memcpy( result, name->string, len );
|
||||
result[len] = '\0';
|
||||
|
||||
face->root.internal->postscript_name = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
|
||||
|
||||
|
||||
@ -127,6 +173,10 @@
|
||||
if ( strcmp( interface, "glyph_name" ) == 0 )
|
||||
return (FT_Module_Interface)get_sfnt_glyph_name;
|
||||
#endif
|
||||
|
||||
if ( strcmp( interface, "postscript_name" ) == 0 )
|
||||
return (FT_Module_Interface)get_sfnt_postscript_name;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,13 @@
|
||||
}
|
||||
|
||||
|
||||
static const char*
|
||||
t1_get_ps_name( T1_Face face )
|
||||
{
|
||||
return (const char*) face->type1.font_name;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
@ -148,6 +155,9 @@
|
||||
if ( strcmp( (const char*)interface, "name_index" ) == 0 )
|
||||
return (FT_Module_Interface)t1_get_name_index;
|
||||
|
||||
if ( strcmp( (const char*)interface, "postscript_name" ) == 0 )
|
||||
return (FT_Module_Interface)t1_get_ps_name;
|
||||
|
||||
#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
|
||||
if ( strcmp( (const char*)interface, "get_mm" ) == 0 )
|
||||
return (FT_Module_Interface)T1_Get_Multi_Master;
|
||||
|
Loading…
Reference in New Issue
Block a user