New parameters for FT_Open_Face() to ignore preferred family names.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
diff --git a/ChangeLog b/ChangeLog
index 0d80490..1ff5af6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/include/freetype/ftsnames.h b/include/freetype/ftsnames.h
index f20b409..50ee08c 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 cef3cd9..f83e1ba 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 */