ref: d4ec0075414a63b6d1850cc801af30e0ef246d92
parent: 44e1f0d3a008f7d6b1c04bbf9553bb06d2c2fed9
author: Werner Lemberg <[email protected]>
date: Sat Sep 15 14:26:28 EDT 2012
[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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2012-09-15 Werner Lemberg <[email protected]>
+ [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 <[email protected]>
+
[autofit] Correct previous Unicode 6.1.0 change.
The auto-hinter's latin module only handles latin ligatures in the
--- a/include/freetype/ftautoh.h
+++ b/include/freetype/ftautoh.h
@@ -246,6 +246,44 @@
} 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
--- 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 );
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -36,12 +36,12 @@
/************************************************************************/
- /* 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_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,
--- 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 =
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -48,9 +48,19 @@
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 ));
return AF_Err_Missing_Property;
@@ -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,7 +105,16 @@
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 ));
return AF_Err_Missing_Property;
@@ -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 );
}
--- a/src/autofit/afmodule.h
+++ b/src/autofit/afmodule.h
@@ -40,7 +40,7 @@
{
FT_ModuleRec root;
- FT_UInt default_script;
+ FT_UInt fallback_script;
AF_LoaderRec loader[1];