[autofit] Implement `fallback-script' property. * src/autofit/afglobal.c: s/default_script/fallback_script/. * src/autofit/afglobal.h: s/AF_SCRIPT_DEFAULT/AF_SCRIPT_FALLBACK/. * src/autofit/afmodule.c: s/default_script/fallback_script/. (af_property_set, af_property_get): Implement `fallback-script'. * src/autofit/afmodule.h: s/default_script/fallback_script/. * include/freetype/ftautoh.h: Document it.
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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
diff --git a/ChangeLog b/ChangeLog
index 5081c33..9df283a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2012-09-15 Werner Lemberg <wl@gnu.org>
+ [autofit] Implement `fallback-script' property.
+
+ * src/autofit/afglobal.c: s/default_script/fallback_script/.
+ * src/autofit/afglobal.h: s/AF_SCRIPT_DEFAULT/AF_SCRIPT_FALLBACK/.
+
+ * src/autofit/afmodule.c: s/default_script/fallback_script/.
+ (af_property_set, af_property_get): Implement `fallback-script'.
+ * src/autofit/afmodule.h: s/default_script/fallback_script/.
+
+ * include/freetype/ftautoh.h: Document it.
+
+2012-09-15 Werner Lemberg <wl@gnu.org>
+
[autofit] Correct previous Unicode 6.1.0 change.
The auto-hinter's latin module only handles latin ligatures in the
diff --git a/include/freetype/ftautoh.h b/include/freetype/ftautoh.h
index b04f8fc..88a65bc 100644
--- a/include/freetype/ftautoh.h
+++ b/include/freetype/ftautoh.h
@@ -246,6 +246,44 @@ FT_BEGIN_HEADER
} FT_Prop_GlyphToScriptMap;
+
+ /**************************************************************************
+ *
+ * @property:
+ * fallback-script
+ *
+ * @description:
+ * If no auto-hinter script module can be assigned to a glyph, a
+ * fallback script gets assigned to it (see also the
+ * @glyph-to-script-map property). By default, this is
+ * @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property,
+ * this fallback value can be changed.
+ *
+ * {
+ * FT_Library library;
+ * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE;
+ *
+ *
+ * FT_Init_FreeType( &library );
+ *
+ * FT_Property_Set( library, "autofitter",
+ * "fallback-script", &fallback_script );
+ * }
+ *
+ * @note:
+ * This property can be used with @FT_Property_Get also.
+ *
+ * It's important to use the right timing for changing this value: The
+ * creation of the glyph-to-script map which eventually uses the
+ * fallback script value gets triggered either by accessing the
+ * @glyph-to-script-map property of a face, or by auto-hinting any glyph
+ * from that face. In particular, if you have already created an
+ * @FT_Face structure but not loaded any glyph (using the auto-hinter),
+ * a change of the fallback glyph will affect this face.
+ *
+ */
+
+
/* */
FT_END_HEADER
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 464e6d5..6a1d286 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -54,7 +54,7 @@
static FT_Error
af_face_globals_compute_script_coverage( AF_FaceGlobals globals,
- FT_UInt default_script )
+ FT_UInt fallback_script )
{
FT_Error error = AF_Err_Ok;
FT_Face face = globals->face;
@@ -73,7 +73,7 @@
if ( error )
{
/*
- * Ignore this error; we simply use the default script.
+ * Ignore this error; we simply use the fallback script.
* XXX: Shouldn't we rather disable hinting?
*/
error = AF_Err_Ok;
@@ -133,7 +133,7 @@
Exit:
/*
- * By default, all uncovered glyphs are set to the latin script.
+ * By default, all uncovered glyphs are set to the fallback script.
* XXX: Shouldn't we disable hinting or do something similar?
*/
{
@@ -145,7 +145,7 @@
if ( ( gscripts[nn] & ~AF_DIGIT ) == AF_SCRIPT_NONE )
{
gscripts[nn] &= ~AF_SCRIPT_NONE;
- gscripts[nn] |= default_script;
+ gscripts[nn] |= fallback_script;
}
}
}
@@ -158,7 +158,7 @@
FT_LOCAL_DEF( FT_Error )
af_face_globals_new( FT_Face face,
AF_FaceGlobals *aglobals,
- FT_UInt default_script )
+ FT_UInt fallback_script )
{
FT_Error error;
FT_Memory memory;
@@ -176,7 +176,7 @@
globals->glyph_scripts = (FT_Byte*)( globals + 1 );
error = af_face_globals_compute_script_coverage( globals,
- default_script );
+ fallback_script );
if ( error )
{
af_face_globals_free( globals );
diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h
index 3dec6d0..27c9251 100644
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -36,12 +36,12 @@ FT_BEGIN_HEADER
/************************************************************************/
- /* index of default script in `af_script_classes' */
-#define AF_SCRIPT_DEFAULT 2
- /* a bit mask indicating an uncovered glyph */
-#define AF_SCRIPT_NONE 0x7F
- /* if this flag is set, we have an ASCII digit */
-#define AF_DIGIT 0x80
+ /* index of fallback script in `af_script_classes' */
+#define AF_SCRIPT_FALLBACK 2
+ /* a bit mask indicating an uncovered glyph */
+#define AF_SCRIPT_NONE 0x7F
+ /* if this flag is set, we have an ASCII digit */
+#define AF_DIGIT 0x80
/*
@@ -70,7 +70,7 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
af_face_globals_new( FT_Face face,
AF_FaceGlobals *aglobals,
- FT_UInt default_script );
+ FT_UInt fallback_script );
FT_LOCAL( FT_Error )
af_face_globals_get_metrics( AF_FaceGlobals globals,
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index 98824dc..975947e 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -60,7 +60,7 @@
if ( loader->globals == NULL )
{
error = af_face_globals_new( face, &loader->globals,
- module->default_script );
+ module->fallback_script );
if ( !error )
{
face->autohint.data =
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index f07ed3c..d4347f0 100644
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -48,8 +48,18 @@
const char* property_name,
const void* value )
{
- FT_UNUSED( module );
- FT_UNUSED( value );
+ FT_Error error = AF_Err_Ok;
+
+
+ if ( !ft_strcmp( property_name, "fallback-script" ) )
+ {
+ FT_UInt* fallback_script = (FT_UInt*)value;
+
+
+ ((AF_Module)module)->fallback_script = *fallback_script;
+
+ return error;
+ }
FT_TRACE0(( "af_property_get: missing property `%s'\n",
property_name ));
@@ -62,8 +72,8 @@
const char* property_name,
void* value )
{
- FT_Error error = AF_Err_Ok;
- FT_UInt default_script = ((AF_Module)module)->default_script;
+ FT_Error error = AF_Err_Ok;
+ FT_UInt fallback_script = ((AF_Module)module)->fallback_script;
if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
@@ -80,7 +90,7 @@
{
/* trigger computation of the global script data */
/* in case it hasn't been done yet */
- error = af_face_globals_new( prop->face, &globals, default_script );
+ error = af_face_globals_new( prop->face, &globals, fallback_script );
if ( !error )
{
prop->face->autohint.data =
@@ -95,6 +105,15 @@
return error;
}
+ else if ( !ft_strcmp( property_name, "fallback-script" ) )
+ {
+ FT_UInt* val = (FT_UInt*)value;
+
+
+ *val = fallback_script;
+
+ return error;
+ }
FT_TRACE0(( "af_property_get: missing property `%s'\n",
property_name ));
@@ -138,7 +157,7 @@
FT_CALLBACK_DEF( FT_Error )
af_autofitter_init( AF_Module module )
{
- module->default_script = AF_SCRIPT_DEFAULT;
+ module->fallback_script = AF_SCRIPT_FALLBACK;
return af_loader_init( module );
}
diff --git a/src/autofit/afmodule.h b/src/autofit/afmodule.h
index 8948c1b..c4e8f8f 100644
--- a/src/autofit/afmodule.h
+++ b/src/autofit/afmodule.h
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
{
FT_ModuleRec root;
- FT_UInt default_script;
+ FT_UInt fallback_script;
AF_LoaderRec loader[1];