зеркало из https://github.com/stride3d/freetype.git
[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.
This commit is contained in:
Родитель
44e1f0d3a0
Коммит
d4ec007541
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ FT_BEGIN_HEADER
|
|||
{
|
||||
FT_ModuleRec root;
|
||||
|
||||
FT_UInt default_script;
|
||||
FT_UInt fallback_script;
|
||||
|
||||
AF_LoaderRec loader[1];
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче