From 75852eda51106579c3b15be83e5ab6b896d54f07 Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Fri, 29 Jan 2010 23:18:34 +0900 Subject: [PATCH] New parameters for FT_Open_Face() to ignore preferred family names. --- ChangeLog | 15 ++++++++++++++ include/freetype/ftsnames.h | 16 +++++++++++++++ src/sfnt/sfobjs.c | 39 +++++++++++++++++++++++++------------ 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d8049047..1ff5af6ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2010-01-29 suzuki toshiya + + New parameters for FT_Open_Face() to ignore preferred family names. + + Preferred family names should be used for legacy systems that + can hold only a few faces (<= 4) for a family name. Suggested by + Andreas Heinrich. + http://lists.gnu.org/archive/html/freetype/2010-01/msg00001.html + + * include/freetype/ftsnames.h (FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY, + FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY): Define. + + * src/sfnt/sfobjs.h (sfnt_load_face): Check the arguments and + ignore preferred family and subfamily names if requested. + 2010-01-27 Ken Sharp Fix Savannah bug #28678. diff --git a/include/freetype/ftsnames.h b/include/freetype/ftsnames.h index f20b4099d..50ee08cee 100644 --- a/include/freetype/ftsnames.h +++ b/include/freetype/ftsnames.h @@ -160,6 +160,22 @@ FT_BEGIN_HEADER FT_SfntName *aname ); + /*************************************************************************** + * + * @constant: + * FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY + * FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY + * + * @description: + * A constant used as the tag of @FT_Parameter structures to make + * FT_Open_Face() ignore preferred family & preferred subfamily names + * in `name' table since OpenType version 1.4. For back compatibility + * with legacy systems which has 4-face-per-family restriction. + * + */ +#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG( 'i', 'g', 'p', 'f' ) +#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG( 'i', 'g', 'p', 's' ) + /* */ diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index cef3cd959..f83e1ba2d 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -26,6 +26,7 @@ #include FT_TRUETYPE_IDS_H #include FT_TRUETYPE_TAGS_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H +#include FT_SFNT_NAMES_H #include "sferrors.h" #ifdef TT_CONFIG_OPTION_BDF @@ -527,13 +528,27 @@ #endif FT_Bool has_outline; FT_Bool is_apple_sbit; + FT_Bool ignore_preferred_family = FALSE; + FT_Bool ignore_preferred_subfamily = FALSE; SFNT_Service sfnt = (SFNT_Service)face->sfnt; FT_UNUSED( face_index ); - FT_UNUSED( num_params ); - FT_UNUSED( params ); + /* Check parameters */ + + { + FT_Int i; + + + for ( i = 0; i < num_params; i++ ) + { + if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY ) + ignore_preferred_family = TRUE; + else if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY ) + ignore_preferred_subfamily = TRUE; + } + } /* Load tables */ @@ -724,27 +739,27 @@ if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 ) { - GET_NAME( PREFERRED_FAMILY, &face->root.family_name ); - if ( !face->root.family_name ) - GET_NAME( FONT_FAMILY, &face->root.family_name ); + GET_NAME( FONT_FAMILY, &face->root.family_name ); + if ( !face->root.family_name || !ignore_preferred_family ) + GET_NAME( PREFERRED_FAMILY, &face->root.family_name ); - GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name ); - if ( !face->root.style_name ) - GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); + GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); + if ( !face->root.style_name || !ignore_preferred_subfamily ) + GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name ); } else { GET_NAME( WWS_FAMILY, &face->root.family_name ); - if ( !face->root.family_name ) - GET_NAME( PREFERRED_FAMILY, &face->root.family_name ); if ( !face->root.family_name ) GET_NAME( FONT_FAMILY, &face->root.family_name ); + if ( !face->root.family_name || !ignore_preferred_family ) + GET_NAME( PREFERRED_FAMILY, &face->root.family_name ); GET_NAME( WWS_SUBFAMILY, &face->root.style_name ); - if ( !face->root.style_name ) - GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name ) GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); + if ( !face->root.style_name || !ignore_preferred_subfamily ) + GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name ); } /* now set up root fields */