diff --git a/ChangeLog b/ChangeLog index 00c8ffc86..b9558cac2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ 2005-05-28 David Turner + * include/freetype/ftxf86.h, src/base/ftxf86.c: added a new API named + 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/base + * src/pshinter/pshglob.c (psh_blues_scale_zones): fixed a bug that prevented family blue zones substitution from hapenning correctly diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h index 0a6788cf2..3e26c9628 100644 --- a/include/freetype/config/ftheader.h +++ b/include/freetype/config/ftheader.h @@ -496,6 +496,8 @@ #define FT_CACHE_INTERNAL_GLYPH_H #define FT_CACHE_INTERNAL_CACHE_H +#define FT_XFREE86_H + /* now include internal headers definitions from */ #define FT_INTERNAL_INTERNAL_H diff --git a/include/freetype/ftxf86.h b/include/freetype/ftxf86.h new file mode 100644 index 000000000..2f2f3429b --- /dev/null +++ b/include/freetype/ftxf86.h @@ -0,0 +1,35 @@ +#ifndef __FT_XFREE86_H__ +#define __FT_XFREE86_H__ + +#include +#include FT_FREETYPE_H + +FT_BEGIN_HEADER + + /* this comment is intentionally disabled for now, to prevent this */ + /* function from appearing in the API Reference. */ + + /*@***********************************************************************/ + /* */ + /* */ + /* FT_Get_X11_Font_Format */ + /* */ + /* */ + /* 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. */ + /* */ + /* */ + /* face :: input face handle. */ + /* */ + /* */ + /* 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__ */ diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h index 951a13392..08f245f3d 100644 --- a/include/freetype/t1tables.h +++ b/include/freetype/t1tables.h @@ -186,7 +186,7 @@ FT_BEGIN_HEADER } T1_Blend_Flags; - /* backwards compatible definitions */ + /*# backwards compatible definitions */ #define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION #define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS #define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE @@ -317,10 +317,65 @@ FT_BEGIN_HEADER /* FreeType. */ /* */ typedef CID_FaceInfoRec CID_Info; - + /* */ + /************************************************************************ + * + * @function: FT_Has_PS_Glyph_Names + * + * @description: + * returns true when a given face provides reliable Postscript glyph + * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro, except + * that certain fonts (mostly TrueType) contain incorrect glyph name + * tables. + * + * when this function returns true, the caller is sure that the glyph + * names returned by @FT_Get_Glyph_Name are reliable. + * + * @input: + * face :: face handle + * + * @return: + * boolean. true if glyph names are reliable + */ + FT_EXPORT( FT_Int ) + FT_Has_PS_Glyph_Names( FT_Face face ); + + + /************************************************************************ + * + * @function: FT_Get_PS_Font_Info + * + * @description: + * retrieve the @PS_FontInfoRec structure corresponding to a given + * Postscript font. + * + * @input: + * face :: postscript face handle + * + * @output: + * afont_info :: output font info structure pointer + * + * @return: + * error code. 0 means success + * + * @note: + * the string pointers within the font info structure are owned by + * the face and don't need to be freed by the caller. + * + * if the font's format is not Postscript-based, this function will + * return the @FT_Err_Invalid_Argument error code. + */ + FT_EXPORT( FT_Error ) + FT_Get_PS_Font_Info( FT_Face face, + PS_FontInfoRec *afont_info ); + + /* */ + + + FT_END_HEADER #endif /* __T1TABLES_H__ */ diff --git a/src/base/Jamfile b/src/base/Jamfile index 76efd28dc..c579b3b98 100644 --- a/src/base/Jamfile +++ b/src/base/Jamfile @@ -23,8 +23,8 @@ SubDirHdrs [ FT2_SubDir src base ] ; # Add the optional/replaceable files. # -Library $(FT2_LIB) : ftsystem.c ftinit.c ftglyph.c ftmm.c ftbdf.c - ftbbox.c ftdebug.c ; +Library $(FT2_LIB) : ftsystem.c ftinit.c ftglyph.c ftmm.c ftbdf.c + ftbbox.c ftdebug.c ftxf86.c fttype1.c ; # Add Macintosh-specific file to the library when necessary. # diff --git a/src/base/descrip.mms b/src/base/descrip.mms index 83bb50804..8639e04d5 100644 --- a/src/base/descrip.mms +++ b/src/base/descrip.mms @@ -15,7 +15,7 @@ CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.builds.vms],[--.include],[--.src.base]) -OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj +OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj,fttype1.obj,ftxf86.obj all : $(OBJS) library [--.lib]freetype.olb $(OBJS) diff --git a/src/base/fttype1.c b/src/base/fttype1.c new file mode 100644 index 000000000..74452384c --- /dev/null +++ b/src/base/fttype1.c @@ -0,0 +1,74 @@ +#include +#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; + } diff --git a/src/base/ftxf86.c b/src/base/ftxf86.c new file mode 100644 index 000000000..dd27c9a00 --- /dev/null +++ b/src/base/ftxf86.c @@ -0,0 +1,56 @@ +#include +#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; + } diff --git a/src/base/rules.mk b/src/base/rules.mk index b27611df7..5f7816dbf 100644 --- a/src/base/rules.mk +++ b/src/base/rules.mk @@ -52,6 +52,8 @@ BASE_SRC := $(BASE_)ftcalc.c \ BASE_EXT_SRC := $(BASE_)ftglyph.c \ $(BASE_)ftmm.c \ $(BASE_)ftbdf.c \ + $(BASE_)fttype1.c \ + $(BASE_)ftxf86.c \ $(BASE_)ftbbox.c # Default extensions objects