New parameters for FT_Open_Face() to ignore preferred family names.

This commit is contained in:
suzuki toshiya 2010-01-29 23:18:34 +09:00
parent f19e46f3ba
commit 75852eda51
3 changed files with 58 additions and 12 deletions

View File

@ -1,3 +1,18 @@
2010-01-29 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
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 <ken.sharp@artifex.com>
Fix Savannah bug #28678.

View File

@ -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' )
/* */

View File

@ -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 */