FT_Get_X11_Font_Format to return an X11-compatible string describing the font format of a given face. This was put in a new optional base source file, corresponding to a new public header (named FT_XFREE86_H since this function should only be used within the XFree86 font server IMO). * include/freetype/config/ftheader.h: adding FT_XFREE86_H, though it's not documented yet. * include/freetype/t1tables.h, src/base/fttype1.c: adding two new APIs named "FT_Get_PS_Font_Info" and "FT_Has_PS_Glyph_Names". This required a new optional source in 'src/base' named "fttype1.c" * src/base/Jamfile, src/base/rules.mk, src/base/descrip.mms: updating build control files for the new files "ftxf86.c" and "fttype1.c" in src/baseBRANCH-2-1-5
parent
0cb062ae96
commit
2359a38374
9 changed files with 246 additions and 5 deletions
@ -0,0 +1,35 @@ |
||||
#ifndef __FT_XFREE86_H__ |
||||
#define __FT_XFREE86_H__ |
||||
|
||||
#include <ft2build.h> |
||||
#include FT_FREETYPE_H |
||||
|
||||
FT_BEGIN_HEADER |
||||
|
||||
/* this comment is intentionally disabled for now, to prevent this */ |
||||
/* function from appearing in the API Reference. */ |
||||
|
||||
/*@***********************************************************************/ |
||||
/* */ |
||||
/* <Function> */ |
||||
/* FT_Get_X11_Font_Format */ |
||||
/* */ |
||||
/* <Description> */ |
||||
/* Returns a string describing the format of a given face as a X11 */ |
||||
/* FONT_PROPERTY. It should only be used by FreeType 2 font backend */ |
||||
/* of the XFree86 font server. */ |
||||
/* */ |
||||
/* <Input> */ |
||||
/* face :: input face handle. */ |
||||
/* */ |
||||
/* <Return> */ |
||||
/* font format string. NULL in case of error. */ |
||||
/* */ |
||||
FT_EXPORT_DEF( const char* ) |
||||
FT_Get_X11_Font_Format( FT_Face face ); |
||||
|
||||
/* */ |
||||
|
||||
FT_END_HEADER |
||||
|
||||
#endif /* __FT_XFREE86_H__ */ |
@ -0,0 +1,74 @@ |
||||
#include <ft2build.h> |
||||
#include FT_INTERNAL_TYPE1_TYPES_H |
||||
#include FT_INTERNAL_OBJECTS_H |
||||
|
||||
/* case a FT_Face to a T1_Face when relevant */ |
||||
/* this implementation sucks, but a lot of things should change in the */ |
||||
/* future anyway.. */ |
||||
/* */ |
||||
static T1_Face |
||||
t1_face_check_cast( FT_Face face ) |
||||
{ |
||||
FT_Module driver; |
||||
T1_Face result = NULL; |
||||
|
||||
if ( face && face->driver != NULL ) |
||||
{ |
||||
driver = (FT_Module) face->driver; |
||||
|
||||
if ( driver->clazz && driver->clazz->module_name && |
||||
ft_strcmp( driver->clazz->module_name, "type1" ) == 0 ) |
||||
{ |
||||
/* correct typecast ! */ |
||||
result = (T1_Face) face; |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
/* documentation is in t1tables.h */ |
||||
|
||||
FT_EXPORT_DEF( FT_Error ) |
||||
FT_Get_PS_Font_Info( FT_Face face, |
||||
PS_FontInfoRec* afont_info ) |
||||
{ |
||||
FT_Error error = FT_Err_Invalid_Argument; |
||||
T1_Face t1_face = t1_face_check_cast( face ); |
||||
|
||||
if ( t1_face != NULL ) |
||||
{ |
||||
*afont_info = t1_face->type1.font_info; |
||||
error = FT_Err_Ok; |
||||
} |
||||
return error; |
||||
} |
||||
|
||||
|
||||
/* XXX: bad hack, but I didn't want to change several drivers here */ |
||||
|
||||
/* documentation is in t1tables.h */ |
||||
|
||||
FT_EXPORT_DEF( FT_Int ) |
||||
FT_Has_PS_Glyph_Names( FT_Face face ) |
||||
{ |
||||
FT_Int result = 0; |
||||
const char* driver_name; |
||||
|
||||
if ( face && face->driver && face->driver->root.clazz ) |
||||
{ |
||||
/* for now, only the type1 and cff drivers provide reliable */ |
||||
/* glyph names... */ |
||||
|
||||
/* we could probably hack the TrueType driver to recognize */ |
||||
/* certain cases where the glyph names are most certainly */ |
||||
/* correct (e.g. using a 20 or 22 format 'post' table), but */ |
||||
/* this will probably happen later... :-) */ |
||||
|
||||
driver_name = face->driver->root.clazz->module_name; |
||||
result = ( ft_strcmp( driver_name, "type1" ) || |
||||
ft_strcmp( driver_name, "cff" ) ); |
||||
} |
||||
return result; |
||||
} |
@ -0,0 +1,56 @@ |
||||
#include <ft2build.h> |
||||
#include FT_XFREE86_H |
||||
#include FT_INTERNAL_OBJECTS_H |
||||
|
||||
/* XXX: this really is a sad hack, but I didn't want to change every */ |
||||
/* driver just to support this at the moment, since other important */ |
||||
/* changes are coming anyway !! */ |
||||
|
||||
typedef struct |
||||
{ |
||||
const char* driver_name; |
||||
const char* format_name; |
||||
|
||||
} FT_FontFormatRec; |
||||
|
||||
|
||||
FT_EXPORT_DEF( const char* ) |
||||
FT_Get_X11_Font_Format( FT_Face face ) |
||||
{ |
||||
static const FT_FontFormatRec font_formats[] = |
||||
{ |
||||
{ "type1", "Type 1" }, |
||||
{ "truetype", "TrueType" }, |
||||
{ "bdf", "BDF" }, |
||||
{ "pcf", "PCF" }, |
||||
{ "type42", "Type 42" }, |
||||
{ "cidtype1", "CID Type 1" }, |
||||
{ "cff", "CFF" }, |
||||
{ "pfr", "PFR" }, |
||||
{ "winfonts", "Windows FNT" } |
||||
}; |
||||
|
||||
const char* result = NULL; |
||||
|
||||
|
||||
if ( face && face->driver ) |
||||
{ |
||||
FT_Module driver = (FT_Module) face->driver; |
||||
|
||||
if ( driver->clazz && driver->clazz->module_name ) |
||||
{ |
||||
FT_Int n, count = sizeof(font_formats)/sizeof(font_formats[0]); |
||||
|
||||
result = driver->clazz->module_name; |
||||
|
||||
for ( n = 0; n < count; n++ ) |
||||
if ( ft_strcmp( result, font_formats[n].driver_name ) == 0 ) |
||||
{ |
||||
result = font_formats[n].format_name; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
return result; |
||||
} |
Loading…
Reference in new issue