ref: 75852eda51106579c3b15be83e5ab6b896d54f07
parent: f19e46f3bae4a8b652d39298cc9f42c9f27bdbeb
author: suzuki toshiya <[email protected]>
date: Fri Jan 29 18:18:34 EST 2010
New parameters for FT_Open_Face() to ignore preferred family names.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2010-01-29 suzuki toshiya <[email protected]>
+
+ 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 <[email protected]>
Fix Savannah bug #28678.
--- a/include/freetype/ftsnames.h
+++ b/include/freetype/ftsnames.h
@@ -160,6 +160,22 @@
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' )
+
/* */
--- 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,14 +528,28 @@
#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 */
/* We now support two SFNT-based bitmapped font formats. They */
@@ -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 */