[autofit] Introduce `styles'.

This is the new top-level structure for handling glyph input data;
scripts are now defined separately.

* src/autofit/aftypes.h (SCRIPT): Updated.
(AF_ScriptClassRec): Move `blue_stringset' and `writing_system'
members to ...
(AF_Style_ClassRec): ... this new structure.
(AF_Style): New enumeration.
(AF_StyleMetricsRec): Replace `script' enumeration with
`style_class' pointer.
(AF_DEFINE_SCRIPT_CLASS, AF_DECLARE_SCRIPT_CLASS): Updated.
(AF_DEFINE_STYLE_CLASS, AF_DECLARE_STYLE_CLASS): New macros.

* src/autofit/afstyles.h: New file, using data from `afscript.h'.
* src/autofit/afscript.h: Updated.

* src/autofit/afcjk.c (af_cjk_metrics_init_widths,
af_cjk_metrics_init_blues, af_cjk_hint_edges): Updated.

* src/autofit/afglobal.c (SCRIPT): Updated.
(STYLE): Redefine macro to load `afstyles.h'.
(af_script_names) [FT_DEBUG_LEVEL_TRACE]: Replace with...
(af_style_names): ... this array.
(af_face_globals_compute_script_coverage): Renamed to...
(af_face_globals_compute_style_coverage): ... this.
Updated.
(af_face_globals_new, af_face_globals_free,
af_face_globals_get_metrics): Updated.

* src/autofit/afglobal.h (SCRIPT): Updated.
(STYLE): Redefine macro to load `afstyles.h'.
(AF_SCRIPT_FALLBACK): Update definition.  This will get more
refinements with later on.
(AF_SCRIPT_UNASSIGNED): Replace with...
(AF_STYLE_UNASSIGNED): ... this macro.
(AF_FaceGlobalsRec): Updated.

* src/autofit/aflatin.c (af_latin_metrics_init_widths,
af_latin_metrics_init_blues, af_latin_metrics_scale_dim,
af_latin_hint_edges): Updated.

* src/autofit/aflatin2.c (af_latin2_metrics_init_widths): Updated.
(af_ltn2_uniranges): Removed.

* src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph):
Updated.

* src/autofit/afpic.c (autofit_module_class_pic_init): Updated.
* src/autofit/afpic.h (AF_STYLE_CLASSES_GET): New macro.
(AFModulePIC): Add `af_style_classes' and `af_style_classes_rec'
members.

* src/autofit/afranges.h: Updated.

* src/autofit/rules.mk (AUTOF_DRV_H): Add `afstyles.h'.
This commit is contained in:
Werner Lemberg 2013-12-20 17:26:26 +01:00
parent d8324571f1
commit 974b193bcc
18 changed files with 388 additions and 181 deletions

View File

@ -1,3 +1,63 @@
2013-12-20 Werner Lemberg <wl@gnu.org>
[autofit] Introduce `styles'.
This is the new top-level structure for handling glyph input data;
scripts are now defined separately.
* src/autofit/aftypes.h (SCRIPT): Updated.
(AF_ScriptClassRec): Move `blue_stringset' and `writing_system'
members to ...
(AF_Style_ClassRec): ... this new structure.
(AF_Style): New enumeration.
(AF_StyleMetricsRec): Replace `script' enumeration with
`style_class' pointer.
(AF_DEFINE_SCRIPT_CLASS, AF_DECLARE_SCRIPT_CLASS): Updated.
(AF_DEFINE_STYLE_CLASS, AF_DECLARE_STYLE_CLASS): New macros.
* src/autofit/afstyles.h: New file, using data from `afscript.h'.
* src/autofit/afscript.h: Updated.
* src/autofit/afcjk.c (af_cjk_metrics_init_widths,
af_cjk_metrics_init_blues, af_cjk_hint_edges): Updated.
* src/autofit/afglobal.c (SCRIPT): Updated.
(STYLE): Redefine macro to load `afstyles.h'.
(af_script_names) [FT_DEBUG_LEVEL_TRACE]: Replace with...
(af_style_names): ... this array.
(af_face_globals_compute_script_coverage): Renamed to...
(af_face_globals_compute_style_coverage): ... this.
Updated.
(af_face_globals_new, af_face_globals_free,
af_face_globals_get_metrics): Updated.
* src/autofit/afglobal.h (SCRIPT): Updated.
(STYLE): Redefine macro to load `afstyles.h'.
(AF_SCRIPT_FALLBACK): Update definition. This will get more
refinements with later on.
(AF_SCRIPT_UNASSIGNED): Replace with...
(AF_STYLE_UNASSIGNED): ... this macro.
(AF_FaceGlobalsRec): Updated.
* src/autofit/aflatin.c (af_latin_metrics_init_widths,
af_latin_metrics_init_blues, af_latin_metrics_scale_dim,
af_latin_hint_edges): Updated.
* src/autofit/aflatin2.c (af_latin2_metrics_init_widths): Updated.
(af_ltn2_uniranges): Removed.
* src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph):
Updated.
* src/autofit/afpic.c (autofit_module_class_pic_init): Updated.
* src/autofit/afpic.h (AF_STYLE_CLASSES_GET): New macro.
(AFModulePIC): Add `af_style_classes' and `af_style_classes_rec'
members.
* src/autofit/afranges.h: Updated.
* src/autofit/rules.mk (AUTOF_DRV_H): Add `afstyles.h'.
2013-12-19 Werner Lemberg <wl@gnu.org>
[autofit] Factor scripts and uniranges out of writing system files.

View File

@ -75,10 +75,10 @@
FT_TRACE5(( "\n"
"cjk standard widths computation (script `%s')\n"
"cjk standard widths computation (style `%s')\n"
"===============================================\n"
"\n",
af_script_names[metrics->root.script] ));
af_style_names[metrics->root.style_class->style] ));
af_glyph_hints_init( hints, face->memory );
@ -92,8 +92,9 @@
AF_CJKMetricsRec dummy[1];
AF_Scaler scaler = &dummy->root.scaler;
AF_ScriptClass script_class =
AF_SCRIPT_CLASSES_GET[metrics->root.script];
AF_StyleClass style_class = metrics->root.style_class;
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[style_class->script];
glyph_index = FT_Get_Char_Index( face, script_class->standard_char );
@ -228,7 +229,7 @@
AF_CJKAxis axis;
FT_Outline outline;
AF_ScriptClass sc = AF_SCRIPT_CLASSES_GET[metrics->root.script];
AF_StyleClass sc = metrics->root.style_class;
AF_Blue_Stringset bss = sc->blue_stringset;
const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
@ -250,9 +251,9 @@
#endif
/* we walk over the blue character strings as specified in the */
/* script's entry in the `af_blue_stringset' array, computing its */
/* extremum points (depending on the string properties) */
/* we walk over the blue character strings as specified in the */
/* style's entry in the `af_blue_stringset' array, computing its */
/* extremum points (depending on the string properties) */
FT_TRACE5(( "cjk blue zones computation\n"
"==========================\n"
@ -1669,9 +1670,9 @@
#endif
FT_TRACE5(( "cjk %s edge hinting (script `%s')\n",
FT_TRACE5(( "cjk %s edge hinting (style `%s')\n",
dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
af_script_names[hints->metrics->script] ));
af_style_names[hints->metrics->style_class->style] ));
/* we begin by aligning all stems relative to the blue zone */

View File

@ -25,9 +25,7 @@
FT_BEGIN_HEADER
/* A dummy writing system and script class used when no hinting should be
* performed.
*/
/* A dummy writing system used when no hinting should be performed. */
AF_DECLARE_WRITING_SYSTEM_CLASS( af_dummy_writing_system_class )

View File

@ -45,12 +45,10 @@
#undef SCRIPT
#define SCRIPT( s, S, d, ss, ws, dc ) \
#define SCRIPT( s, S, d, dc ) \
AF_DEFINE_SCRIPT_CLASS( \
af_ ## s ## _script_class, \
AF_SCRIPT_ ## S, \
ss, \
ws, \
af_ ## s ## _uniranges, \
dc )
@ -58,7 +56,7 @@
#undef SCRIPT
#define SCRIPT( s, S, d, ss, ws, dc ) \
#define SCRIPT( s, S, d, dc ) \
&af_ ## s ## _script_class,
FT_LOCAL_ARRAY_DEF( AF_ScriptClass )
@ -70,29 +68,55 @@
NULL /* do not remove */
};
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss ) \
AF_DEFINE_STYLE_CLASS( \
af_ ## s ## _style_class, \
AF_STYLE_ ## S, \
ws, \
sc, \
ss )
#include "afstyles.h"
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss ) \
&af_ ## s ## _style_class,
FT_LOCAL_ARRAY_DEF( AF_StyleClass )
af_style_classes[] =
{
#include "afstyles.h"
NULL /* do not remove */
};
#endif /* !FT_CONFIG_OPTION_PIC */
#ifdef FT_DEBUG_LEVEL_TRACE
#undef SCRIPT
#define SCRIPT( s, S, d, ss, ws, dc ) #s,
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss ) #s,
FT_LOCAL_ARRAY_DEF( char* )
af_script_names[] =
af_style_names[] =
{
#include "afscript.h"
#include "afstyles.h"
};
#endif /* FT_DEBUG_LEVEL_TRACE */
/* Compute the script index of each glyph within a given face. */
/* Compute the style index of each glyph within a given face. */
static FT_Error
af_face_globals_compute_script_coverage( AF_FaceGlobals globals )
af_face_globals_compute_style_coverage( AF_FaceGlobals globals )
{
FT_Error error;
FT_Face face = globals->face;
@ -102,9 +126,9 @@
FT_UInt i;
/* the value AF_SCRIPT_UNASSIGNED means `uncovered glyph' */
/* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
FT_MEM_SET( globals->glyph_styles,
AF_SCRIPT_UNASSIGNED,
AF_STYLE_UNASSIGNED,
globals->glyph_count );
error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
@ -118,10 +142,13 @@
goto Exit;
}
/* scan each script in a Unicode charmap */
for ( ss = 0; AF_SCRIPT_CLASSES_GET[ss]; ss++ )
/* scan each style in a Unicode charmap */
for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
{
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET[ss];
AF_StyleClass style_class =
AF_STYLE_CLASSES_GET[ss];
AF_ScriptClass script_class =
AF_SCRIPT_CLASSES_GET[style_class->script];
AF_Script_UniRange range;
@ -130,7 +157,7 @@
/*
* Scan all Unicode points in the range and set the corresponding
* glyph script index.
* glyph style index.
*/
for ( range = script_class->script_uni_ranges;
range->first != 0;
@ -144,7 +171,7 @@
if ( gindex != 0 &&
gindex < (FT_ULong)globals->glyph_count &&
gstyles[gindex] == AF_SCRIPT_UNASSIGNED )
gstyles[gindex] == AF_STYLE_UNASSIGNED )
gstyles[gindex] = (FT_Byte)ss;
for (;;)
@ -155,7 +182,7 @@
break;
if ( gindex < (FT_ULong)globals->glyph_count &&
gstyles[gindex] == AF_SCRIPT_UNASSIGNED )
gstyles[gindex] == AF_STYLE_UNASSIGNED )
gstyles[gindex] = (FT_Byte)ss;
}
}
@ -176,16 +203,16 @@
* By default, all uncovered glyphs are set to the fallback script.
* XXX: Shouldn't we disable hinting or do something similar?
*/
if ( globals->module->fallback_script != AF_SCRIPT_UNASSIGNED )
if ( globals->module->fallback_script != AF_STYLE_UNASSIGNED )
{
FT_Long nn;
for ( nn = 0; nn < globals->glyph_count; nn++ )
{
if ( ( gstyles[nn] & ~AF_DIGIT ) == AF_SCRIPT_UNASSIGNED )
if ( ( gstyles[nn] & ~AF_DIGIT ) == AF_STYLE_UNASSIGNED )
{
gstyles[nn] &= ~AF_SCRIPT_UNASSIGNED;
gstyles[nn] &= ~AF_STYLE_UNASSIGNED;
gstyles[nn] |= globals->module->fallback_script;
}
}
@ -217,7 +244,7 @@
globals->glyph_styles = (FT_Byte*)( globals + 1 );
globals->module = module;
error = af_face_globals_compute_script_coverage( globals );
error = af_face_globals_compute_style_coverage( globals );
if ( error )
{
af_face_globals_free( globals );
@ -241,14 +268,14 @@
FT_UInt nn;
for ( nn = 0; nn < AF_SCRIPT_MAX; nn++ )
for ( nn = 0; nn < AF_STYLE_MAX; nn++ )
{
if ( globals->metrics[nn] )
{
AF_ScriptClass script_class =
AF_SCRIPT_CLASSES_GET[nn];
AF_StyleClass style_class =
AF_STYLE_CLASSES_GET[nn];
AF_WritingSystemClass writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[script_class->writing_system];
AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
if ( writing_system_class->style_metrics_done )
@ -275,9 +302,9 @@
{
AF_StyleMetrics metrics = NULL;
AF_Script script = (AF_Script)( options & 15 );
AF_Style style = (AF_Style)( options & 15 );
AF_WritingSystemClass writing_system_class;
AF_ScriptClass script_class;
AF_StyleClass style_class;
FT_Error error = FT_Err_Ok;
@ -288,17 +315,17 @@
goto Exit;
}
/* if we have a forced script (via `options'), use it, */
/* otherwise look into `glyph_styles' array */
if ( script == AF_SCRIPT_NONE || script + 1 >= AF_SCRIPT_MAX )
script = (AF_Script)( globals->glyph_styles[gindex] &
AF_SCRIPT_UNASSIGNED );
/* if we have a forced style (via `options'), use it, */
/* otherwise look into `glyph_styles' array */
if ( style == AF_STYLE_NONE_DEFAULT || style + 1 >= AF_STYLE_MAX )
style = (AF_Style)( globals->glyph_styles[gindex] &
AF_STYLE_UNASSIGNED );
script_class = AF_SCRIPT_CLASSES_GET[script];
style_class = AF_STYLE_CLASSES_GET[style];
writing_system_class = AF_WRITING_SYSTEM_CLASSES_GET
[script_class->writing_system];
[style_class->writing_system];
metrics = globals->metrics[script];
metrics = globals->metrics[style];
if ( metrics == NULL )
{
/* create the global metrics object if necessary */
@ -308,8 +335,8 @@
if ( FT_ALLOC( metrics, writing_system_class->style_metrics_size ) )
goto Exit;
metrics->script = script;
metrics->globals = globals;
metrics->style_class = style_class;
metrics->globals = globals;
if ( writing_system_class->style_metrics_init )
{
@ -325,7 +352,7 @@
}
}
globals->metrics[script] = metrics;
globals->metrics[style] = metrics;
}
Exit:

View File

@ -32,7 +32,7 @@ FT_BEGIN_HEADER
af_writing_system_classes[];
#undef SCRIPT
#define SCRIPT( s, S, d, ss, ws, dc ) \
#define SCRIPT( s, S, d, dc ) \
AF_DECLARE_SCRIPT_CLASS( af_ ## s ## _script_class )
#include "afscript.h"
@ -40,24 +40,36 @@ FT_BEGIN_HEADER
FT_LOCAL_ARRAY( AF_ScriptClass )
af_script_classes[];
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss ) \
AF_DECLARE_STYLE_CLASS( af_ ## s ## _style_class )
#include "afstyles.h"
FT_LOCAL_ARRAY( AF_StyleClass )
af_style_classes[];
#ifdef FT_DEBUG_LEVEL_TRACE
FT_LOCAL_ARRAY( char* )
af_script_names[];
af_style_names[];
#endif
/*
* Default values and flags for both autofitter globals (found in
* AF_ModuleRec) and face globals (in AF_FaceGlobalsRec).
*/
/* index of fallback script in `af_script_classes' */
/* index of fallback script in `af_style_classes' */
#ifdef AF_CONFIG_OPTION_CJK
#define AF_SCRIPT_FALLBACK AF_SCRIPT_HANI
#define AF_SCRIPT_FALLBACK AF_STYLE_HANI_DEFAULT
#else
#define AF_SCRIPT_FALLBACK AF_SCRIPT_NONE
#define AF_SCRIPT_FALLBACK AF_STYLE_NONE_DEFAULT
#endif
/* a bit mask indicating an uncovered glyph */
#define AF_SCRIPT_UNASSIGNED 0x7F
#define AF_STYLE_UNASSIGNED 0x7F
/* if this flag is set, we have an ASCII digit */
#define AF_DIGIT 0x80
@ -77,7 +89,7 @@ FT_BEGIN_HEADER
/*
* Note that glyph_styles[] maps each glyph to an index into the
* `af_script_classes' array.
* `af_style_classes' array.
*
*/
typedef struct AF_FaceGlobalsRec_
@ -89,7 +101,7 @@ FT_BEGIN_HEADER
/* per-face auto-hinter properties */
FT_UInt increase_x_height;
AF_StyleMetrics metrics[AF_SCRIPT_MAX];
AF_StyleMetrics metrics[AF_STYLE_MAX];
AF_Module module; /* to access global properties */
@ -98,7 +110,7 @@ FT_BEGIN_HEADER
/*
* model the global hints data for a given face, decomposed into
* script-specific items
* style-specific items
*/
FT_LOCAL( FT_Error )

View File

@ -27,7 +27,7 @@ FT_BEGIN_HEADER
/*
* The definition of outline glyph hints. These are shared by all
* script analysis routines (until now).
* writing system analysis routines (until now).
*/
typedef enum AF_Dimension_
@ -361,9 +361,9 @@ FT_BEGIN_HEADER
AF_AxisHintsRec axis[AF_DIMENSION_MAX];
FT_UInt32 scaler_flags; /* copy of scaler flags */
FT_UInt32 other_flags; /* free for script-specific */
/* implementations */
FT_UInt32 scaler_flags; /* copy of scaler flags */
FT_UInt32 other_flags; /* free for style-specific */
/* implementations */
AF_StyleMetrics metrics;
FT_Pos xmin_delta; /* used for warping */

View File

@ -62,10 +62,10 @@
FT_TRACE5(( "\n"
"latin standard widths computation (script `%s')\n"
"=================================================\n"
"latin standard widths computation (style `%s')\n"
"================================================\n"
"\n",
af_script_names[metrics->root.script] ));
af_style_names[metrics->root.style_class->style] ));
af_glyph_hints_init( hints, face->memory );
@ -79,8 +79,9 @@
AF_LatinMetricsRec dummy[1];
AF_Scaler scaler = &dummy->root.scaler;
AF_ScriptClass script_class =
AF_SCRIPT_CLASSES_GET[metrics->root.script];
AF_StyleClass style_class = metrics->root.style_class;
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[style_class->script];
glyph_index = FT_Get_Char_Index( face, script_class->standard_char );
@ -216,14 +217,14 @@
AF_LatinAxis axis = &metrics->axis[AF_DIMENSION_VERT];
FT_Outline outline;
AF_ScriptClass sc = AF_SCRIPT_CLASSES_GET[metrics->root.script];
AF_StyleClass sc = metrics->root.style_class;
AF_Blue_Stringset bss = sc->blue_stringset;
const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
/* we walk over the blue character strings as specified in the */
/* script's entry in the `af_blue_stringset' array */
/* we walk over the blue character strings as specified in the */
/* style's entry in the `af_blue_stringset' array */
FT_TRACE5(( "latin blue zones computation\n"
"============================\n"
@ -883,11 +884,11 @@
FT_TRACE5((
"af_latin_metrics_scale_dim:"
" x height alignment (script `%s'):\n"
" x height alignment (style `%s'):\n"
" "
" vertical scaling changed from %.4f to %.4f (by %d%%)\n"
"\n",
af_script_names[metrics->root.script],
af_style_names[metrics->root.style_class->style],
axis->org_scale / 65536.0,
scale / 65536.0,
( fitted - scaled ) * 100 / scaled ));
@ -910,9 +911,9 @@
metrics->root.scaler.y_delta = delta;
}
FT_TRACE5(( "%s widths (script `%s')\n",
FT_TRACE5(( "%s widths (style `%s')\n",
dim == AF_DIMENSION_HORZ ? "horizontal" : "vertical",
af_script_names[metrics->root.script] ));
af_style_names[metrics->root.style_class->style] ));
/* scale the widths */
for ( nn = 0; nn < axis->width_count; nn++ )
@ -937,15 +938,15 @@
#ifdef FT_DEBUG_LEVEL_TRACE
if ( axis->extra_light )
FT_TRACE5(( "`%s' script is extra light (at current resolution)\n"
FT_TRACE5(( "`%s' style is extra light (at current resolution)\n"
"\n",
af_script_names[metrics->root.script] ));
af_style_names[metrics->root.style_class->style] ));
#endif
if ( dim == AF_DIMENSION_VERT )
{
FT_TRACE5(( "blue zones (script `%s')\n",
af_script_names[metrics->root.script] ));
FT_TRACE5(( "blue zones (style `%s')\n",
af_style_names[metrics->root.style_class->style] ));
/* scale the blue zones */
for ( nn = 0; nn < axis->blue_count; nn++ )
@ -2152,9 +2153,9 @@
#endif
FT_TRACE5(( "latin %s edge hinting (script `%s')\n",
FT_TRACE5(( "latin %s edge hinting (style `%s')\n",
dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
af_script_names[hints->metrics->script] ));
af_style_names[hints->metrics->style_class->style] ));
/* we begin by aligning all stems relative to the blue zone */
/* if needed -- that's only for horizontal edges */

View File

@ -46,8 +46,8 @@ FT_BEGIN_HEADER
/*
* The following declarations could be embedded in the file `aflatin.c';
* they have been made semi-public to allow alternate script hinters to
* re-use some of them.
* they have been made semi-public to allow alternate writing system
* hinters to re-use some of them.
*/
@ -161,7 +161,7 @@ FT_BEGIN_HEADER
/*
* The next functions shouldn't normally be exported. However, other
* scripts might like to use these functions as-is.
* writing systems might like to use these functions as-is.
*/
FT_LOCAL( FT_Error )
af_latin_hints_compute_segments( AF_GlyphHints hints,

View File

@ -78,7 +78,7 @@
glyph_index = FT_Get_Char_Index(
face,
metrics->root.script_class->standard_char );
metrics->root.style_class->standard_char );
if ( glyph_index == 0 )
goto Exit;
@ -2396,41 +2396,4 @@
)
/* XXX: this should probably fine tuned to differentiate better between */
/* scripts... */
static const AF_Script_UniRangeRec af_ltn2_uniranges[] =
{
AF_UNIRANGE_REC( 0x0020UL, 0x007FUL ), /* Basic Latin (no control chars) */
AF_UNIRANGE_REC( 0x00A0UL, 0x00FFUL ), /* Latin-1 Supplement (no control chars) */
AF_UNIRANGE_REC( 0x0100UL, 0x017FUL ), /* Latin Extended-A */
AF_UNIRANGE_REC( 0x0180UL, 0x024FUL ), /* Latin Extended-B */
AF_UNIRANGE_REC( 0x0250UL, 0x02AFUL ), /* IPA Extensions */
AF_UNIRANGE_REC( 0x02B0UL, 0x02FFUL ), /* Spacing Modifier Letters */
AF_UNIRANGE_REC( 0x0300UL, 0x036FUL ), /* Combining Diacritical Marks */
AF_UNIRANGE_REC( 0x0370UL, 0x03FFUL ), /* Greek and Coptic */
AF_UNIRANGE_REC( 0x0400UL, 0x04FFUL ), /* Cyrillic */
AF_UNIRANGE_REC( 0x0500UL, 0x052FUL ), /* Cyrillic Supplement */
AF_UNIRANGE_REC( 0x1D00UL, 0x1D7FUL ), /* Phonetic Extensions */
AF_UNIRANGE_REC( 0x1D80UL, 0x1DBFUL ), /* Phonetic Extensions Supplement */
AF_UNIRANGE_REC( 0x1DC0UL, 0x1DFFUL ), /* Combining Diacritical Marks Supplement */
AF_UNIRANGE_REC( 0x1E00UL, 0x1EFFUL ), /* Latin Extended Additional */
AF_UNIRANGE_REC( 0x1F00UL, 0x1FFFUL ), /* Greek Extended */
AF_UNIRANGE_REC( 0x2000UL, 0x206FUL ), /* General Punctuation */
AF_UNIRANGE_REC( 0x2070UL, 0x209FUL ), /* Superscripts and Subscripts */
AF_UNIRANGE_REC( 0x20A0UL, 0x20CFUL ), /* Currency Symbols */
AF_UNIRANGE_REC( 0x2150UL, 0x218FUL ), /* Number Forms */
AF_UNIRANGE_REC( 0x2460UL, 0x24FFUL ), /* Enclosed Alphanumerics */
AF_UNIRANGE_REC( 0x2C60UL, 0x2C7FUL ), /* Latin Extended-C */
AF_UNIRANGE_REC( 0x2DE0UL, 0x2DFFUL ), /* Cyrillic Extended-A */
AF_UNIRANGE_REC( 0x2E00UL, 0x2E7FUL ), /* Supplemental Punctuation */
AF_UNIRANGE_REC( 0xA640UL, 0xA69FUL ), /* Cyrillic Extended-B */
AF_UNIRANGE_REC( 0xA720UL, 0xA7FFUL ), /* Latin Extended-D */
AF_UNIRANGE_REC( 0xFB00UL, 0xFB06UL ), /* Alphab. Present. Forms (Latin Ligs) */
AF_UNIRANGE_REC( 0x1D400UL, 0x1D7FFUL ), /* Mathematical Alphanumeric Symbols */
AF_UNIRANGE_REC( 0x1F100UL, 0x1F1FFUL ), /* Enclosed Alphanumeric Supplement */
AF_UNIRANGE_REC( 0UL, 0UL )
};
/* END */

View File

@ -185,10 +185,9 @@
#ifdef FT_CONFIG_OPTION_PIC
AF_FaceGlobals globals = loader->globals;
#endif
AF_ScriptClass script_class =
AF_SCRIPT_CLASSES_GET[metrics->script];
AF_StyleClass style_class = metrics->style_class;
AF_WritingSystemClass writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[script_class->writing_system];
AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
if ( writing_system_class->style_hints_apply )
@ -531,13 +530,13 @@
if ( !error )
{
AF_StyleMetrics metrics;
FT_UInt options = AF_SCRIPT_NONE;
FT_UInt options = AF_STYLE_NONE_DEFAULT;
#ifdef FT_OPTION_AUTOFIT2
/* XXX: undocumented hook to activate the latin2 writing system */
if ( load_flags & ( 1UL << 20 ) )
options = AF_SCRIPT_LTN2;
options = AF_STYLE_LTN2_DEFAULT;
#endif
error = af_face_globals_get_metrics( loader->globals, gindex,
@ -547,10 +546,9 @@
#ifdef FT_CONFIG_OPTION_PIC
AF_FaceGlobals globals = loader->globals;
#endif
AF_ScriptClass script_class =
AF_SCRIPT_CLASSES_GET[metrics->script];
AF_StyleClass style_class = metrics->style_class;
AF_WritingSystemClass writing_system_class =
AF_WRITING_SYSTEM_CLASSES_GET[script_class->writing_system];
AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system];
loader->metrics = metrics;

View File

@ -60,8 +60,8 @@
globals = (AF_FaceGlobals)face->autohint.data;
if ( !globals )
{
/* trigger computation of the global script data */
/* in case it hasn't been done yet */
/* trigger computation of the global style data */
/* in case it hasn't been done yet */
error = af_face_globals_new( face, &globals, module );
if ( !error )
{

View File

@ -42,7 +42,7 @@
FT_AutoHinter_InterfaceRec* clazz );
/* forward declaration of PIC init functions from script classes */
/* forward declaration of PIC init functions from writing system classes */
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) /* empty */
@ -107,6 +107,11 @@
&container->af_script_classes_rec[ss];
container->af_script_classes[AF_SCRIPT_MAX - 1] = NULL;
for ( ss = 0; ss < AF_STYLE_MAX - 1; ss++ )
container->af_style_classes[ss] =
&container->af_style_classes_rec[ss];
container->af_style_classes[AF_STYLE_MAX - 1] = NULL;
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) \
FT_Init_Class_af_ ## ws ## _writing_system_class( \
@ -116,13 +121,21 @@
#include "afwrtsys.h"
#undef SCRIPT
#define SCRIPT( s, S, d, ss, ws, dc ) \
#define SCRIPT( s, S, d, dc ) \
FT_Init_Class_af_ ## s ## _script_class( \
&container->af_script_classes_rec[ss++] );
ss = 0;
#include "afscript.h"
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss ) \
FT_Init_Class_af_ ## s ## _style_class( \
&container->af_style_classes_rec[ss++] );
ss = 0;
#include "afstyles.h"
FT_Init_Class_af_autofitter_interface(
library, &container->af_autofitter_interface );

View File

@ -32,6 +32,7 @@ FT_BEGIN_HEADER
#define AF_WRITING_SYSTEM_CLASSES_GET af_writing_system_classes
#define AF_SCRIPT_CLASSES_GET af_script_classes
#define AF_STYLE_CLASSES_GET af_style_classes
#define AF_INTERFACE_GET af_autofitter_interface
#else /* FT_CONFIG_OPTION_PIC */
@ -57,6 +58,11 @@ FT_BEGIN_HEADER
AF_ScriptClassRec af_script_classes_rec
[AF_SCRIPT_MAX - 1];
AF_StyleClass af_style_classes
[AF_STYLE_MAX];
AF_StyleClassRec af_style_classes_rec
[AF_STYLE_MAX - 1];
FT_AutoHinter_InterfaceRec af_autofitter_interface;
} AFModulePIC;
@ -74,6 +80,8 @@ FT_BEGIN_HEADER
( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_writing_system_classes )
#define AF_SCRIPT_CLASSES_GET \
( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_script_classes )
#define AF_STYLE_CLASSES_GET \
( GET_PIC( FT_FACE_LIBRARY( globals->face ) )->af_style_classes )
#define AF_INTERFACE_GET \
( GET_PIC( library )->af_autofitter_interface )

View File

@ -26,7 +26,7 @@
FT_BEGIN_HEADER
#undef SCRIPT
#define SCRIPT( s, S, d, ss, ws, dc ) \
#define SCRIPT( s, S, d, dc ) \
extern const AF_Script_UniRangeRec af_ ## s ## _uniranges[];
#include "afscript.h"

View File

@ -24,53 +24,31 @@
SCRIPT( cyrl, CYRL,
"Cyrillic",
AF_BLUE_STRINGSET_CYRL,
AF_WRITING_SYSTEM_LATIN,
0x43E ) /* о */
SCRIPT( deva, DEVA,
"Indic scripts",
(AF_Blue_Stringset)0, /* XXX */
AF_WRITING_SYSTEM_INDIC,
'o' ) /* XXX */
SCRIPT( none, NONE,
"no script",
(AF_Blue_Stringset)0,
AF_WRITING_SYSTEM_DUMMY,
'\0' )
SCRIPT( grek, GREK,
"Greek",
AF_BLUE_STRINGSET_GREK,
AF_WRITING_SYSTEM_LATIN,
0x3BF ) /* ο */
SCRIPT( hani, HANI,
"CJKV ideographs",
AF_BLUE_STRINGSET_HANI,
AF_WRITING_SYSTEM_CJK,
0x7530 ) /* 田 */
SCRIPT( hebr, HEBR,
"Hebrew",
AF_BLUE_STRINGSET_HEBR,
AF_WRITING_SYSTEM_LATIN,
0x5DD ) /* ם */
SCRIPT( latn, LATN,
"Latin",
AF_BLUE_STRINGSET_LATN,
AF_WRITING_SYSTEM_LATIN,
'o' )
#ifdef FT_OPTION_AUTOFIT2
SCRIPT( ltn2, LTN2,
"Latin 2",
AF_BLUE_STRINGSET_LATN,
AF_WRITING_SYSTEM_LATIN2,
'o' )
#endif
/* END */

76
src/autofit/afstyles.h Normal file
View File

@ -0,0 +1,76 @@
/***************************************************************************/
/* */
/* afstyles.h */
/* */
/* Auto-fitter styles (specification only). */
/* */
/* Copyright 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
/* The following part can be included multiple times. */
/* Define `STYLE' as needed. */
/* Add new styles here. */
STYLE( cyrl_default, CYRL_DEFAULT,
"Cyrillic default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_CYRL,
AF_BLUE_STRINGSET_CYRL )
STYLE( deva_default, DEVA_DEFAULT,
"Indic scripts default style",
AF_WRITING_SYSTEM_INDIC,
AF_SCRIPT_DEVA,
(AF_Blue_Stringset)0 ) /* XXX */
STYLE( none_default, NONE_DEFAULT,
"no style",
AF_WRITING_SYSTEM_DUMMY,
AF_SCRIPT_NONE,
(AF_Blue_Stringset)0 )
STYLE( grek_default, GREK_DEFAULT,
"Greek default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_GREK,
AF_BLUE_STRINGSET_GREK )
STYLE( hani_default, HANI_DEFAULT,
"CJKV ideographs default style",
AF_WRITING_SYSTEM_CJK,
AF_SCRIPT_HANI,
AF_BLUE_STRINGSET_HANI )
STYLE( hebr_default, HEBR_DEFAULT,
"Hebrew default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_HEBR,
AF_BLUE_STRINGSET_HEBR )
STYLE( latn_default, LATN_DEFAULT,
"Latin default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_LATN,
AF_BLUE_STRINGSET_LATN )
#ifdef FT_OPTION_AUTOFIT2
STYLE( ltn2_default, LTN2_DEFAULT,
"Latin 2 default style",
AF_WRITING_SYSTEM_LATIN2,
AF_SCRIPT_LATN,
AF_BLUE_STRINGSET_LATN )
#endif
/* END */

View File

@ -20,7 +20,7 @@
*
* The auto-fitter is a complete rewrite of the old auto-hinter.
* Its main feature is the ability to differentiate between different
* writing systems in order to apply script-specific rules.
* writing systems and scripts in order to apply specific rules.
*
* The code has also been compartmentized into several entities that
* should make algorithmic experimentation easier than with the old
@ -200,7 +200,7 @@ extern void* _af_debug_hints;
typedef struct AF_StyleMetricsRec_* AF_StyleMetrics;
/* This function parses an FT_Face to compute global metrics for
* a specific script.
* a specific style.
*/
typedef FT_Error
(*AF_WritingSystem_InitMetricsFunc)( AF_StyleMetrics metrics,
@ -296,14 +296,14 @@ extern void* _af_debug_hints;
/*
* Each script is associated with a set of Unicode ranges that gets used
* to test whether the font face supports the script. It also references
* the writing system it belongs to.
* to test whether the font face supports the script.
*
* We use four-letter script tags from the OpenType specification.
* We use four-letter script tags from the OpenType specification,
* extended by `NONE', which indicates `no script'.
*/
#undef SCRIPT
#define SCRIPT( s, S, d, ss, ws, dc ) \
#define SCRIPT( s, S, d, dc ) \
AF_SCRIPT_ ## S,
/* The list of known scripts. */
@ -331,9 +331,7 @@ extern void* _af_debug_hints;
typedef struct AF_ScriptClassRec_
{
AF_Script script;
AF_Blue_Stringset blue_stringset;
AF_WritingSystem writing_system;
AF_Script script;
AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
FT_UInt32 standard_char; /* for default width and height */
@ -343,6 +341,47 @@ extern void* _af_debug_hints;
typedef const AF_ScriptClassRec* AF_ScriptClass;
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** S T Y L E S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* The topmost structure for modelling the auto-hinter glyph input data
* is a `style class', grouping everything together.
*/
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss ) \
AF_STYLE_ ## S,
/* The list of known styles. */
typedef enum AF_Style_
{
#include "afstyles.h"
AF_STYLE_MAX /* do not remove */
} AF_Style;
typedef struct AF_StyleClassRec_
{
AF_Style style;
AF_WritingSystem writing_system;
AF_Script script;
AF_Blue_Stringset blue_stringset;
} AF_StyleClassRec;
typedef const AF_StyleClassRec* AF_StyleClass;
/*************************************************************************/
/*************************************************************************/
/***** *****/
@ -359,7 +398,7 @@ extern void* _af_debug_hints;
typedef struct AF_StyleMetricsRec_
{
AF_Script script;
AF_StyleClass style_class;
AF_ScalerRec scaler;
FT_Bool digits_have_same_width;
@ -406,21 +445,37 @@ extern void* _af_debug_hints;
#define AF_DEFINE_SCRIPT_CLASS( \
script_class, \
script_, \
blue_stringset_, \
writing_system_, \
script, \
ranges, \
std_char ) \
FT_CALLBACK_TABLE_DEF \
const AF_ScriptClassRec script_class = \
{ \
script_, \
blue_stringset_, \
writing_system_, \
script, \
ranges, \
std_char \
};
#define AF_DECLARE_STYLE_CLASS( style_class ) \
FT_CALLBACK_TABLE const AF_StyleClassRec \
style_class;
#define AF_DEFINE_STYLE_CLASS( \
style_class, \
style, \
writing_system, \
script, \
blue_stringset ) \
FT_CALLBACK_TABLE_DEF \
const AF_StyleClassRec style_class = \
{ \
style, \
writing_system, \
script, \
blue_stringset \
};
#else /* FT_CONFIG_OPTION_PIC */
#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \
@ -458,21 +513,37 @@ extern void* _af_debug_hints;
#define AF_DEFINE_SCRIPT_CLASS( \
script_class, \
script_, \
blue_string_set_, \
writing_system_, \
script, \
ranges, \
std_char ) \
FT_LOCAL_DEF( void ) \
FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \
{ \
ac->script = script_; \
ac->blue_stringset = blue_stringset_; \
ac->writing_system = writing_system_; \
ac->script = script; \
ac->script_uni_ranges = ranges; \
ac->standard_char = std_char; \
}
#define AF_DECLARE_STYLE_CLASS( style_class ) \
FT_LOCAL( void ) \
FT_Init_Class_ ## style_class( AF_StyleClassRec* ac );
#define AF_DEFINE_STYLE_CLASS( \
style_class, \
style, \
writing_system, \
script, \
blue_stringset ) \
FT_LOCAL_DEF( void ) \
FT_Init_Class_ ## style_class( AF_StyleClassRec* ac ) \
{ \
ac->style = style; \
ac->writing_system = writing_system; \
ac->script = script; \
ac->blue_stringset = blue_stringset; \
}
#endif /* FT_CONFIG_OPTION_PIC */

View File

@ -44,6 +44,7 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h) \
$(AUTOF_DIR)/aferrors.h \
$(AUTOF_DIR)/afscript.h \
$(AUTOF_DIR)/afstyles.h \
$(AUTOF_DIR)/aftypes.h \
$(AUTOF_DIR)/afwrtsys.h