[autofit] Introduce `warping' property.
This code replaces the debugging hook from the previous commit with a better, more generic solution. * include/ftautoh.h: Document it. * src/autofit/afmodule.h (AF_ModuleRec) [AF_CONFIG_OPTION_USE_WARPER]: Add `warping' field. * src/autofit/afmodule.c (_af_debug_disable_warper): Remove. (af_property_set, af_property_get, af_autofitter_init) [AF_CONFIG_OPTION_USE_WARPER]: Handle `warping' option. * src/autofit/afhints.h (AF_HINTS_DO_WARP): Remove use of the no longer existing `_af_debug_disable_warper'. * src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c (af_latin_hints_init), src/autofit/aflatin2.c (af_latin2_hints_init) [AF_CONFIG_OPTION_USE_WARPER]: Add `AF_SCALER_FLAG_NO_WARPER' to the scaler flags if warping is off. * src/autofit/aftypes.h: Updated.
This commit is contained in:
parent
b51f01583f
commit
12661a5ae0
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
||||
2015-04-21 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[autofit] Introduce `warping' property.
|
||||
|
||||
This code replaces the debugging hook from the previous commit with
|
||||
a better, more generic solution.
|
||||
|
||||
* include/ftautoh.h: Document it.
|
||||
|
||||
* src/autofit/afmodule.h (AF_ModuleRec)
|
||||
[AF_CONFIG_OPTION_USE_WARPER]: Add `warping' field.
|
||||
|
||||
* src/autofit/afmodule.c (_af_debug_disable_warper): Remove.
|
||||
(af_property_set, af_property_get, af_autofitter_init)
|
||||
[AF_CONFIG_OPTION_USE_WARPER]: Handle `warping' option.
|
||||
|
||||
* src/autofit/afhints.h (AF_HINTS_DO_WARP): Remove use of the no
|
||||
longer existing `_af_debug_disable_warper'.
|
||||
|
||||
* src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c
|
||||
(af_latin_hints_init), src/autofit/aflatin2.c (af_latin2_hints_init)
|
||||
[AF_CONFIG_OPTION_USE_WARPER]: Add `AF_SCALER_FLAG_NO_WARPER' to the
|
||||
scaler flags if warping is off.
|
||||
|
||||
* src/autofit/aftypes.h: Updated.
|
||||
|
||||
2015-04-16 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[autofit] Add debugging hook to disable warper.
|
||||
|
@ -820,8 +820,10 @@ FT_BEGIN_HEADER
|
||||
/* grid. To find out the optimal scaling and shifting value, various */
|
||||
/* parameter combinations are tried and scored. */
|
||||
/* */
|
||||
/* This experimental option is only active if the render mode is */
|
||||
/* FT_RENDER_MODE_LIGHT. */
|
||||
/* This experimental option is active only if the rendering mode is */
|
||||
/* FT_RENDER_MODE_LIGHT; you can switch warping on and off with the */
|
||||
/* `warping' property of the auto-hinter (see file `ftautoh.h' for more */
|
||||
/* information). */
|
||||
/* */
|
||||
#define AF_CONFIG_OPTION_USE_WARPER
|
||||
|
||||
|
@ -820,8 +820,10 @@ FT_BEGIN_HEADER
|
||||
/* grid. To find out the optimal scaling and shifting value, various */
|
||||
/* parameter combinations are tried and scored. */
|
||||
/* */
|
||||
/* This experimental option is only active if the render mode is */
|
||||
/* FT_RENDER_MODE_LIGHT. */
|
||||
/* This experimental option is active only if the rendering mode is */
|
||||
/* FT_RENDER_MODE_LIGHT; you can switch warping on and off with the */
|
||||
/* `warping' property of the auto-hinter (see file `ftautoh.h' for more */
|
||||
/* information). */
|
||||
/* */
|
||||
/* #define AF_CONFIG_OPTION_USE_WARPER */
|
||||
|
||||
|
@ -300,7 +300,7 @@ FT_BEGIN_HEADER
|
||||
* @description:
|
||||
* *Experimental* *only*
|
||||
*
|
||||
* If Freetype gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make
|
||||
* If FreeType gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make
|
||||
* the HarfBuzz library access OpenType features for getting better
|
||||
* glyph coverages, this property sets the (auto-fitter) script to be
|
||||
* used for the default (OpenType) script data of a font's GSUB table.
|
||||
@ -391,6 +391,54 @@ FT_BEGIN_HEADER
|
||||
|
||||
} FT_Prop_IncreaseXHeight;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* warping
|
||||
*
|
||||
* @description:
|
||||
* *Experimental* *only*
|
||||
*
|
||||
* If FreeType gets compiled with option AF_CONFIG_OPTION_USE_WARPER to
|
||||
* activate the warp hinting code in the auto-hinter, this property
|
||||
* switches warping on and off.
|
||||
*
|
||||
* Warping only works in `light' auto-hinting mode. The idea of the
|
||||
* code is to slightly scale and shift a glyph along the non-hinted
|
||||
* dimension (which is usually the horizontal axis) so that as much of
|
||||
* its segments are aligned (more or less) to the grid. To find out a
|
||||
* glyph's optimal scaling and shifting value, various parameter
|
||||
* combinations are tried and scored.
|
||||
*
|
||||
* By default, warping is on. The example below shows how to switch off
|
||||
* warping (omitting the error handling).
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_Bool warping = 0;
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
*
|
||||
* FT_Property_Set( library, "autofitter",
|
||||
* "warping", &warping );
|
||||
* }
|
||||
*
|
||||
* @note:
|
||||
* This property can be used with @FT_Property_Get also.
|
||||
*
|
||||
* The warping code can also change advance widths. Have a look at the
|
||||
* `lsb_delta' and `rsb_delta' fields in the @FT_GlyphSlotRec structure
|
||||
* for details on improving inter-glyph distances while rendering.
|
||||
*
|
||||
* Since warping is a global property of the auto-hinter it is best to
|
||||
* change its value before rendering any face. Otherwise, you should
|
||||
* reload all faces that get auto-hinted in `light' hinting mode.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
|
@ -1334,6 +1334,12 @@
|
||||
|
||||
scaler_flags |= AF_SCALER_FLAG_NO_ADVANCE;
|
||||
|
||||
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
||||
/* get (global) warper flag */
|
||||
if ( !metrics->root.globals->module->warping )
|
||||
scaler_flags |= AF_SCALER_FLAG_NO_WARPER;
|
||||
#endif
|
||||
|
||||
hints->scaler_flags = scaler_flags;
|
||||
hints->other_flags = other_flags;
|
||||
|
||||
|
@ -382,15 +382,8 @@ FT_BEGIN_HEADER
|
||||
( !_af_debug_disable_vert_hints && \
|
||||
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL ) )
|
||||
|
||||
#define AF_HINTS_DO_ADVANCE( h ) \
|
||||
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
|
||||
|
||||
#define AF_HINTS_DO_BLUES( h ) ( !_af_debug_disable_blue_hints )
|
||||
|
||||
#define AF_HINTS_DO_WARP( h ) \
|
||||
( !_af_debug_disable_warper && \
|
||||
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_WARPER ) )
|
||||
|
||||
#else /* !FT_DEBUG_AUTOFIT */
|
||||
|
||||
#define AF_HINTS_DO_HORIZONTAL( h ) \
|
||||
@ -399,15 +392,17 @@ FT_BEGIN_HEADER
|
||||
#define AF_HINTS_DO_VERTICAL( h ) \
|
||||
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL )
|
||||
|
||||
#define AF_HINTS_DO_BLUES( h ) 1
|
||||
|
||||
#endif /* !FT_DEBUG_AUTOFIT */
|
||||
|
||||
|
||||
#define AF_HINTS_DO_ADVANCE( h ) \
|
||||
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
|
||||
|
||||
#define AF_HINTS_DO_BLUES( h ) 1
|
||||
|
||||
#define AF_HINTS_DO_WARP( h ) \
|
||||
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_WARPER )
|
||||
|
||||
#endif /* !FT_DEBUG_AUTOFIT */
|
||||
|
||||
|
||||
FT_LOCAL( AF_Direction )
|
||||
|
@ -2004,6 +2004,12 @@
|
||||
( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 )
|
||||
scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL;
|
||||
|
||||
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
||||
/* get (global) warper flag */
|
||||
if ( !metrics->root.globals->module->warping )
|
||||
scaler_flags |= AF_SCALER_FLAG_NO_WARPER;
|
||||
#endif
|
||||
|
||||
hints->scaler_flags = scaler_flags;
|
||||
hints->other_flags = other_flags;
|
||||
|
||||
|
@ -1550,6 +1550,12 @@
|
||||
( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 )
|
||||
scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL;
|
||||
|
||||
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
||||
/* get (global) warper flag */
|
||||
if ( !metrics->root.globals->module->warping )
|
||||
scaler_flags |= AF_SCALER_FLAG_NO_WARPER;
|
||||
#endif
|
||||
|
||||
hints->scaler_flags = scaler_flags;
|
||||
hints->other_flags = other_flags;
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
int _af_debug_disable_horz_hints;
|
||||
int _af_debug_disable_vert_hints;
|
||||
int _af_debug_disable_blue_hints;
|
||||
int _af_debug_disable_warper;
|
||||
|
||||
/* we use a global object instead of a local one for debugging */
|
||||
AF_GlyphHintsRec _af_debug_hints_rec[1];
|
||||
@ -146,6 +145,17 @@
|
||||
|
||||
return error;
|
||||
}
|
||||
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
||||
else if ( !ft_strcmp( property_name, "warping" ) )
|
||||
{
|
||||
FT_Bool* warping = (FT_Bool*)value;
|
||||
|
||||
|
||||
module->warping = *warping;
|
||||
|
||||
return error;
|
||||
}
|
||||
#endif /* AF_CONFIG_OPTION_USE_WARPER */
|
||||
|
||||
FT_TRACE0(( "af_property_set: missing property `%s'\n",
|
||||
property_name ));
|
||||
@ -162,6 +172,9 @@
|
||||
AF_Module module = (AF_Module)ft_module;
|
||||
FT_UInt fallback_style = module->fallback_style;
|
||||
FT_UInt default_script = module->default_script;
|
||||
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
||||
FT_Bool warping = module->warping;
|
||||
#endif
|
||||
|
||||
|
||||
if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
|
||||
@ -208,8 +221,18 @@
|
||||
|
||||
return error;
|
||||
}
|
||||
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
||||
else if ( !ft_strcmp( property_name, "warping" ) )
|
||||
{
|
||||
FT_Bool* val = (FT_Bool*)value;
|
||||
|
||||
|
||||
*val = warping;
|
||||
|
||||
return error;
|
||||
}
|
||||
#endif /* AF_CONFIG_OPTION_USE_WARPER */
|
||||
|
||||
FT_TRACE0(( "af_property_get: missing property `%s'\n",
|
||||
property_name ));
|
||||
return FT_THROW( Missing_Property );
|
||||
@ -257,6 +280,9 @@
|
||||
|
||||
module->fallback_style = AF_STYLE_FALLBACK;
|
||||
module->default_script = AF_SCRIPT_DEFAULT;
|
||||
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
||||
module->warping = 1;
|
||||
#endif
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*
|
||||
* This is the `extended' FT_Module structure which holds the
|
||||
* This is the `extended' FT_Module structure that holds the
|
||||
* autofitter's global data.
|
||||
*/
|
||||
|
||||
@ -38,11 +38,14 @@ FT_BEGIN_HEADER
|
||||
|
||||
FT_UInt fallback_style;
|
||||
FT_UInt default_script;
|
||||
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
||||
FT_Bool warping;
|
||||
#endif
|
||||
|
||||
} AF_ModuleRec, *AF_Module;
|
||||
|
||||
|
||||
FT_DECLARE_MODULE(autofit_module_class)
|
||||
FT_DECLARE_MODULE( autofit_module_class )
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
@ -59,7 +59,6 @@ FT_BEGIN_HEADER
|
||||
extern int _af_debug_disable_horz_hints;
|
||||
extern int _af_debug_disable_vert_hints;
|
||||
extern int _af_debug_disable_blue_hints;
|
||||
extern int _af_debug_disable_warper;
|
||||
extern void* _af_debug_hints;
|
||||
|
||||
#endif /* FT_DEBUG_AUTOFIT */
|
||||
|
Loading…
Reference in New Issue
Block a user