mirror of https://github.com/freetype/freetype
[autofit] Introduce `writing systems'.
This patch adds a new top level to the auto-hinter's script class hierarchy. It defines `writing systems' which can contain multiple scripts. For example, the `latin' writing system (in file `aflatin.c') is able to support scripts like Latin, Cyrillic, Armenian, etc., which can be handled similarly. Scripts are now named using four-letter OpenType tags. * src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members to... (AF_WritingSystemClassRec): This new structure. It holds pointers to functions which can be shared among related scripts. (AF_WritingSystem): New enumeration. (AF_Script): Revised values using four-letter tags. (AF_DEFINE_WRITING_SYSTEM_CLASS): New macro. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/afglobal.c (af_writing_system_classes): New global, constant array. (af_script_classes): Updated. (af_face_globals_free): Updated. Remove assertion. (af_face_globals_get_metrics): Updated. * src/autofit/afglobal.h (AF_SCRIPT_FALLBACK) [!AF_CONFIG_OPTION_CJK]: Handle this case. * src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph): Updated. * src/autofit/afpic.c (autofit_module_class_pic_init): Updated; initialize structures for both writing systems and scripts. * src/autofit/afpic.h: Updated. (AF_WRITING_SYSTEM_CLASSES_GET): New macro. * src/autofit/afcjk.c (af_cjk_writing_system_class): New writing system. (af_cjk_uniranges): Renamed to... (af_hani_uniranges): This. (af_cjk_script_class): Reduced and renamed to... (af_hani_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): New writing system. (af_dummy_script_class): Reduced and renamed to... (af_dflt_script_class): This. * src/autofit/afdummy.h: Updated. * src/autofit/afindic.c (af_indic_writing_system_class): New writing system. (af_indic_uniranges): Renamed to... (af_deva_uniranges): This. (af_indic_script_class): Reduced and renamed to... (af_deva_script_class): This. * src/autofit/afcjk.h: Updated. * src/autofit/aflatin.c (af_latin_writing_system_class): New writing system. (af_latin_uniranges): Renamed to... (af_latn_uniranges): This. (af_latin_script_class): Reduced and renamed to... (af_latn_script_class): This. * src/autofit/aflatin.h: Updated. * src/autofit/aflatin2.c (af_latin2_writing_system_class): New writing system. (af_latin2_uniranges): Renamed to... (af_ltn2_uniranges): This. Synchronize ranges with `latin'. (af_latin2_script_class): Reduced and renamed to... (af_ltn2_script_class): This. * src/autofit/aflatin2.h: Updated.
This commit is contained in:
parent
5d6a360542
commit
72f5ff5bbb
80
ChangeLog
80
ChangeLog
|
@ -1,3 +1,83 @@
|
|||
2013-07-30 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[autofit] Introduce `writing systems'.
|
||||
|
||||
This patch adds a new top level to the auto-hinter's script class
|
||||
hierarchy. It defines `writing systems' which can contain multiple
|
||||
scripts.
|
||||
|
||||
For example, the `latin' writing system (in file `aflatin.c') is
|
||||
able to support scripts like Latin, Cyrillic, Armenian, etc., which
|
||||
can be handled similarly.
|
||||
|
||||
Scripts are now named using four-letter OpenType tags.
|
||||
|
||||
* src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members
|
||||
to...
|
||||
(AF_WritingSystemClassRec): This new structure. It holds pointers
|
||||
to functions which can be shared among related scripts.
|
||||
(AF_WritingSystem): New enumeration.
|
||||
(AF_Script): Revised values using four-letter tags.
|
||||
(AF_DEFINE_WRITING_SYSTEM_CLASS): New macro.
|
||||
(AF_DEFINE_SCRIPT_CLASS): Updated.
|
||||
|
||||
* src/autofit/afglobal.c (af_writing_system_classes): New global,
|
||||
constant array.
|
||||
(af_script_classes): Updated.
|
||||
(af_face_globals_free): Updated.
|
||||
Remove assertion.
|
||||
(af_face_globals_get_metrics): Updated.
|
||||
|
||||
* src/autofit/afglobal.h (AF_SCRIPT_FALLBACK)
|
||||
[!AF_CONFIG_OPTION_CJK]: Handle this case.
|
||||
|
||||
* src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph):
|
||||
Updated.
|
||||
|
||||
* src/autofit/afpic.c (autofit_module_class_pic_init): Updated;
|
||||
initialize structures for both writing systems and scripts.
|
||||
* src/autofit/afpic.h: Updated.
|
||||
(AF_WRITING_SYSTEM_CLASSES_GET): New macro.
|
||||
|
||||
* src/autofit/afcjk.c (af_cjk_writing_system_class): New writing
|
||||
system.
|
||||
(af_cjk_uniranges): Renamed to...
|
||||
(af_hani_uniranges): This.
|
||||
(af_cjk_script_class): Reduced and renamed to...
|
||||
(af_hani_script_class): This.
|
||||
* src/autofit/afcjk.h: Updated.
|
||||
|
||||
* src/autofit/afdummy.c (af_dummy_writing_system_class): New writing
|
||||
system.
|
||||
(af_dummy_script_class): Reduced and renamed to...
|
||||
(af_dflt_script_class): This.
|
||||
* src/autofit/afdummy.h: Updated.
|
||||
|
||||
* src/autofit/afindic.c (af_indic_writing_system_class): New writing
|
||||
system.
|
||||
(af_indic_uniranges): Renamed to...
|
||||
(af_deva_uniranges): This.
|
||||
(af_indic_script_class): Reduced and renamed to...
|
||||
(af_deva_script_class): This.
|
||||
* src/autofit/afcjk.h: Updated.
|
||||
|
||||
* src/autofit/aflatin.c (af_latin_writing_system_class): New writing
|
||||
system.
|
||||
(af_latin_uniranges): Renamed to...
|
||||
(af_latn_uniranges): This.
|
||||
(af_latin_script_class): Reduced and renamed to...
|
||||
(af_latn_script_class): This.
|
||||
* src/autofit/aflatin.h: Updated.
|
||||
|
||||
* src/autofit/aflatin2.c (af_latin2_writing_system_class): New
|
||||
writing system.
|
||||
(af_latin2_uniranges): Renamed to...
|
||||
(af_ltn2_uniranges): This.
|
||||
Synchronize ranges with `latin'.
|
||||
(af_latin2_script_class): Reduced and renamed to...
|
||||
(af_ltn2_script_class): This.
|
||||
* src/autofit/aflatin2.h: Updated.
|
||||
|
||||
2013-07-30 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[autofit] Variable renaming.
|
||||
|
|
|
@ -2192,9 +2192,28 @@
|
|||
/*************************************************************************/
|
||||
|
||||
|
||||
AF_DEFINE_WRITING_SYSTEM_CLASS(
|
||||
af_cjk_writing_system_class,
|
||||
|
||||
AF_WRITING_SYSTEM_CJK,
|
||||
|
||||
sizeof ( AF_CJKMetricsRec ),
|
||||
|
||||
(AF_Script_InitMetricsFunc) af_cjk_metrics_init,
|
||||
(AF_Script_ScaleMetricsFunc)af_cjk_metrics_scale,
|
||||
(AF_Script_DoneMetricsFunc) NULL,
|
||||
|
||||
(AF_Script_InitHintsFunc) af_cjk_hints_init,
|
||||
(AF_Script_ApplyHintsFunc) af_cjk_hints_apply
|
||||
)
|
||||
|
||||
|
||||
/* this corresponds to Unicode 6.0 */
|
||||
|
||||
static const AF_Script_UniRangeRec af_cjk_uniranges[] =
|
||||
/* XXX: this should probably fine tuned to differentiate better between */
|
||||
/* scripts... */
|
||||
|
||||
static const AF_Script_UniRangeRec af_hani_uniranges[] =
|
||||
{
|
||||
AF_UNIRANGE_REC( 0x1100UL, 0x11FFUL ), /* Hangul Jamo */
|
||||
AF_UNIRANGE_REC( 0x2E80UL, 0x2EFFUL ), /* CJK Radicals Supplement */
|
||||
|
@ -2232,33 +2251,12 @@
|
|||
};
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS( af_cjk_script_class,
|
||||
AF_SCRIPT_CJK,
|
||||
af_cjk_uniranges,
|
||||
0x7530, /* 田 */
|
||||
|
||||
sizeof ( AF_CJKMetricsRec ),
|
||||
|
||||
(AF_Script_InitMetricsFunc) af_cjk_metrics_init,
|
||||
(AF_Script_ScaleMetricsFunc)af_cjk_metrics_scale,
|
||||
(AF_Script_DoneMetricsFunc) NULL,
|
||||
|
||||
(AF_Script_InitHintsFunc) af_cjk_hints_init,
|
||||
(AF_Script_ApplyHintsFunc) af_cjk_hints_apply
|
||||
)
|
||||
|
||||
#else /* !AF_CONFIG_OPTION_CJK */
|
||||
|
||||
static const AF_Script_UniRangeRec af_cjk_uniranges[] =
|
||||
{
|
||||
AF_UNIRANGE_REC( 0UL, 0UL )
|
||||
};
|
||||
AF_DEFINE_WRITING_SYSTEM_CLASS(
|
||||
af_cjk_writing_system_class,
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS( af_cjk_script_class,
|
||||
AF_SCRIPT_CJK,
|
||||
af_cjk_uniranges,
|
||||
0,
|
||||
AF_WRITING_SYSTEM_CJK,
|
||||
|
||||
sizeof ( AF_CJKMetricsRec ),
|
||||
|
||||
|
@ -2270,7 +2268,24 @@
|
|||
(AF_Script_ApplyHintsFunc) NULL
|
||||
)
|
||||
|
||||
|
||||
static const AF_Script_UniRangeRec af_hani_uniranges[] =
|
||||
{
|
||||
AF_UNIRANGE_REC( 0UL, 0UL )
|
||||
};
|
||||
|
||||
#endif /* !AF_CONFIG_OPTION_CJK */
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS(
|
||||
af_hani_script_class,
|
||||
|
||||
AF_SCRIPT_HANI,
|
||||
AF_WRITING_SYSTEM_CJK,
|
||||
|
||||
af_hani_uniranges,
|
||||
0x7530 /* 田 */
|
||||
)
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* Auto-fitter hinting routines for CJK script (specification). */
|
||||
/* */
|
||||
/* Copyright 2006, 2007, 2011, 2012 by */
|
||||
/* Copyright 2006, 2007, 2011-2013 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -26,9 +26,15 @@
|
|||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/* the CJK-specific script class */
|
||||
/* the CJK-specific writing system */
|
||||
|
||||
AF_DECLARE_WRITING_SYSTEM_CLASS( af_cjk_writing_system_class )
|
||||
|
||||
|
||||
/* the CJK-specific script classes */
|
||||
|
||||
AF_DECLARE_SCRIPT_CLASS( af_hani_script_class )
|
||||
|
||||
AF_DECLARE_SCRIPT_CLASS( af_cjk_script_class )
|
||||
|
||||
/* CJK (global) metrics management */
|
||||
|
||||
|
|
|
@ -43,10 +43,10 @@
|
|||
}
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS( af_dummy_script_class,
|
||||
AF_SCRIPT_DUMMY,
|
||||
NULL,
|
||||
0,
|
||||
AF_DEFINE_WRITING_SYSTEM_CLASS(
|
||||
af_dummy_writing_system_class,
|
||||
|
||||
AF_WRITING_SYSTEM_DUMMY,
|
||||
|
||||
sizeof ( AF_ScriptMetricsRec ),
|
||||
|
||||
|
@ -59,4 +59,15 @@
|
|||
)
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS(
|
||||
af_dflt_script_class,
|
||||
|
||||
AF_SCRIPT_DFLT,
|
||||
AF_WRITING_SYSTEM_DUMMY,
|
||||
|
||||
NULL,
|
||||
'\0'
|
||||
)
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
/* Auto-fitter dummy routines to be used if no hinting should be */
|
||||
/* performed (specification). */
|
||||
/* */
|
||||
/* Copyright 2003-2005, 2011 by */
|
||||
/* Copyright 2003-2005, 2011, 2013 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -25,11 +25,13 @@
|
|||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/* A dummy script metrics class used when no hinting should
|
||||
* be performed. This is the default for non-latin glyphs!
|
||||
/* A dummy writing system and script class used when no hinting should be
|
||||
* performed.
|
||||
*/
|
||||
|
||||
AF_DECLARE_SCRIPT_CLASS( af_dummy_script_class )
|
||||
AF_DECLARE_WRITING_SYSTEM_CLASS( af_dummy_writing_system_class )
|
||||
|
||||
AF_DECLARE_SCRIPT_CLASS( af_dflt_script_class )
|
||||
|
||||
/* */
|
||||
|
||||
|
|
|
@ -31,19 +31,36 @@
|
|||
|
||||
#ifndef FT_CONFIG_OPTION_PIC
|
||||
|
||||
/* when updating this table, don't forget to update */
|
||||
/* AF_WRITING_SYSTEM_CLASSES_COUNT and autofit_module_class_pic_init */
|
||||
|
||||
/* populate this list when you add new writing systems */
|
||||
static AF_WritingSystemClass const af_writing_system_classes[] =
|
||||
{
|
||||
&af_dummy_writing_system_class,
|
||||
&af_latin_writing_system_class,
|
||||
&af_cjk_writing_system_class,
|
||||
&af_indic_writing_system_class,
|
||||
#ifdef FT_OPTION_AUTOFIT2
|
||||
&af_latin2_writing_system_class,
|
||||
#endif
|
||||
NULL /* do not remove */
|
||||
};
|
||||
|
||||
|
||||
/* when updating this table, don't forget to update */
|
||||
/* AF_SCRIPT_CLASSES_COUNT and autofit_module_class_pic_init */
|
||||
|
||||
/* populate this list when you add new scripts */
|
||||
static AF_ScriptClass const af_script_classes[] =
|
||||
{
|
||||
&af_dummy_script_class,
|
||||
&af_dflt_script_class, /* XXX */
|
||||
&af_latn_script_class,
|
||||
&af_hani_script_class,
|
||||
&af_deva_script_class,
|
||||
#ifdef FT_OPTION_AUTOFIT2
|
||||
&af_latin2_script_class,
|
||||
&af_ltn2_script_class,
|
||||
#endif
|
||||
&af_latin_script_class,
|
||||
&af_cjk_script_class,
|
||||
&af_indic_script_class,
|
||||
NULL /* do not remove */
|
||||
};
|
||||
|
||||
|
@ -206,13 +223,14 @@
|
|||
{
|
||||
if ( globals->metrics[nn] )
|
||||
{
|
||||
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET[nn];
|
||||
AF_ScriptClass script_class =
|
||||
AF_SCRIPT_CLASSES_GET[nn];
|
||||
AF_WritingSystemClass writing_system_class =
|
||||
AF_WRITING_SYSTEM_CLASSES_GET[script_class->writing_system];
|
||||
|
||||
|
||||
FT_ASSERT( globals->metrics[nn]->script_class == script_class );
|
||||
|
||||
if ( script_class->script_metrics_done )
|
||||
script_class->script_metrics_done( globals->metrics[nn] );
|
||||
if ( writing_system_class->script_metrics_done )
|
||||
writing_system_class->script_metrics_done( globals->metrics[nn] );
|
||||
|
||||
FT_FREE( globals->metrics[nn] );
|
||||
}
|
||||
|
@ -235,11 +253,14 @@
|
|||
{
|
||||
AF_ScriptMetrics metrics = NULL;
|
||||
FT_UInt gidx;
|
||||
AF_ScriptClass script_class;
|
||||
FT_UInt script = options & 15;
|
||||
const FT_Offset script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) /
|
||||
sizeof ( AF_SCRIPT_CLASSES_GET[0] );
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
AF_WritingSystemClass writing_system_class;
|
||||
AF_ScriptClass script_class;
|
||||
|
||||
FT_UInt script = options & 15;
|
||||
const FT_Offset script_max = sizeof ( AF_SCRIPT_CLASSES_GET ) /
|
||||
sizeof ( AF_SCRIPT_CLASSES_GET[0] );
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
|
||||
if ( gindex >= (FT_ULong)globals->glyph_count )
|
||||
|
@ -252,7 +273,9 @@
|
|||
if ( gidx == 0 || gidx + 1 >= script_max )
|
||||
gidx = globals->glyph_scripts[gindex] & AF_SCRIPT_NONE;
|
||||
|
||||
script_class = AF_SCRIPT_CLASSES_GET[gidx];
|
||||
script_class = AF_SCRIPT_CLASSES_GET[gidx];
|
||||
writing_system_class = AF_WRITING_SYSTEM_CLASSES_GET
|
||||
[script_class->writing_system];
|
||||
if ( script == 0 )
|
||||
script = script_class->script;
|
||||
|
||||
|
@ -263,19 +286,20 @@
|
|||
FT_Memory memory = globals->face->memory;
|
||||
|
||||
|
||||
if ( FT_ALLOC( metrics, script_class->script_metrics_size ) )
|
||||
if ( FT_ALLOC( metrics, writing_system_class->script_metrics_size ) )
|
||||
goto Exit;
|
||||
|
||||
metrics->script_class = script_class;
|
||||
metrics->globals = globals;
|
||||
|
||||
if ( script_class->script_metrics_init )
|
||||
if ( writing_system_class->script_metrics_init )
|
||||
{
|
||||
error = script_class->script_metrics_init( metrics, globals->face );
|
||||
error = writing_system_class->script_metrics_init( metrics,
|
||||
globals->face );
|
||||
if ( error )
|
||||
{
|
||||
if ( script_class->script_metrics_done )
|
||||
script_class->script_metrics_done( metrics );
|
||||
if ( writing_system_class->script_metrics_done )
|
||||
writing_system_class->script_metrics_done( metrics );
|
||||
|
||||
FT_FREE( metrics );
|
||||
goto Exit;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
/* Auto-fitter routines to compute global hinting values */
|
||||
/* (specification). */
|
||||
/* */
|
||||
/* Copyright 2003-2005, 2007, 2009, 2011-2012 by */
|
||||
/* Copyright 2003-2005, 2007, 2009, 2011-2013 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -34,7 +34,11 @@ FT_BEGIN_HEADER
|
|||
*/
|
||||
|
||||
/* index of fallback script in `af_script_classes' */
|
||||
#define AF_SCRIPT_FALLBACK 2
|
||||
#ifdef AF_CONFIG_OPTION_CJK
|
||||
#define AF_SCRIPT_FALLBACK 2 /* hani */
|
||||
#else
|
||||
#define AF_SCRIPT_FALLBACK 0 /* dflt */
|
||||
#endif
|
||||
/* a bit mask indicating an uncovered glyph */
|
||||
#define AF_SCRIPT_NONE 0x7F
|
||||
/* if this flag is set, we have an ASCII digit */
|
||||
|
@ -55,8 +59,8 @@ FT_BEGIN_HEADER
|
|||
|
||||
|
||||
/*
|
||||
* Note that glyph_scripts[] is used to map each glyph into
|
||||
* an index into the `af_script_classes' array.
|
||||
* Note that glyph_scripts[] maps each glyph to an index into the
|
||||
* `af_script_classes' array.
|
||||
*
|
||||
*/
|
||||
typedef struct AF_FaceGlobalsRec_
|
||||
|
|
|
@ -97,26 +97,10 @@
|
|||
/*************************************************************************/
|
||||
|
||||
|
||||
static const AF_Script_UniRangeRec af_indic_uniranges[] =
|
||||
{
|
||||
#if 0
|
||||
AF_UNIRANGE_REC( 0x0100UL, 0xFFFFUL ), /* why this? */
|
||||
#endif
|
||||
AF_UNIRANGE_REC( 0x0900UL, 0x0DFFUL), /* Indic Range */
|
||||
AF_UNIRANGE_REC( 0x0F00UL, 0x0FFFUL), /* Tibetan */
|
||||
AF_UNIRANGE_REC( 0x1900UL, 0x194FUL), /* Limbu */
|
||||
AF_UNIRANGE_REC( 0x1B80UL, 0x1BBFUL), /* Sundanese */
|
||||
AF_UNIRANGE_REC( 0x1C80UL, 0x1CDFUL), /* Meetei Mayak */
|
||||
AF_UNIRANGE_REC( 0xA800UL, 0xA82FUL), /* Syloti Nagri */
|
||||
AF_UNIRANGE_REC( 0x11800UL, 0x118DFUL), /* Sharada */
|
||||
AF_UNIRANGE_REC( 0UL, 0UL)
|
||||
};
|
||||
AF_DEFINE_WRITING_SYSTEM_CLASS(
|
||||
af_indic_writing_system_class,
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS( af_indic_script_class,
|
||||
AF_SCRIPT_INDIC,
|
||||
af_indic_uniranges,
|
||||
'o', /* XXX */
|
||||
AF_WRITING_SYSTEM_INDIC,
|
||||
|
||||
sizeof ( AF_CJKMetricsRec ),
|
||||
|
||||
|
@ -128,18 +112,28 @@
|
|||
(AF_Script_ApplyHintsFunc) af_indic_hints_apply
|
||||
)
|
||||
|
||||
#else /* !AF_CONFIG_OPTION_INDIC */
|
||||
/* XXX: this should probably fine tuned to differentiate better between */
|
||||
/* scripts... */
|
||||
|
||||
static const AF_Script_UniRangeRec af_indic_uniranges[] =
|
||||
static const AF_Script_UniRangeRec af_deva_uniranges[] =
|
||||
{
|
||||
{ 0, 0 }
|
||||
AF_UNIRANGE_REC( 0x0900UL, 0x0DFFUL ), /* Indic Range */
|
||||
AF_UNIRANGE_REC( 0x0F00UL, 0x0FFFUL ), /* Tibetan */
|
||||
AF_UNIRANGE_REC( 0x1900UL, 0x194FUL ), /* Limbu */
|
||||
AF_UNIRANGE_REC( 0x1B80UL, 0x1BBFUL ), /* Sundanese */
|
||||
AF_UNIRANGE_REC( 0x1C80UL, 0x1CDFUL ), /* Meetei Mayak */
|
||||
AF_UNIRANGE_REC( 0xA800UL, 0xA82FUL ), /* Syloti Nagri */
|
||||
AF_UNIRANGE_REC( 0x11800UL, 0x118DFUL ), /* Sharada */
|
||||
AF_UNIRANGE_REC( 0UL, 0UL )
|
||||
};
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS( af_indic_script_class,
|
||||
AF_SCRIPT_INDIC,
|
||||
af_indic_uniranges,
|
||||
0,
|
||||
#else /* !AF_CONFIG_OPTION_INDIC */
|
||||
|
||||
AF_DEFINE_WRITING_SYSTEM_CLASS(
|
||||
af_indic_writing_system_class,
|
||||
|
||||
AF_WRITING_SYSTEM_INDIC,
|
||||
|
||||
sizeof ( AF_CJKMetricsRec ),
|
||||
|
||||
|
@ -151,7 +145,24 @@
|
|||
(AF_Script_ApplyHintsFunc) NULL
|
||||
)
|
||||
|
||||
|
||||
static const AF_Script_UniRangeRec af_deva_uniranges[] =
|
||||
{
|
||||
AF_UNIRANGE_REC( 0UL, 0UL )
|
||||
};
|
||||
|
||||
#endif /* !AF_CONFIG_OPTION_INDIC */
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS(
|
||||
af_deva_script_class,
|
||||
|
||||
AF_SCRIPT_DEVA,
|
||||
AF_WRITING_SYSTEM_INDIC,
|
||||
|
||||
af_deva_uniranges,
|
||||
'o' /* XXX */
|
||||
)
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* Auto-fitter hinting routines for Indic scripts (specification). */
|
||||
/* */
|
||||
/* Copyright 2007, 2012 by */
|
||||
/* Copyright 2007, 2012, 2013 by */
|
||||
/* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -25,9 +25,14 @@
|
|||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/* the Indic-specific script class */
|
||||
/* the `indic' writing system */
|
||||
|
||||
AF_DECLARE_SCRIPT_CLASS( af_indic_script_class )
|
||||
AF_DECLARE_WRITING_SYSTEM_CLASS( af_indic_writing_system_class )
|
||||
|
||||
|
||||
/* the indic-specific script classes */
|
||||
|
||||
AF_DECLARE_SCRIPT_CLASS( af_deva_script_class )
|
||||
|
||||
|
||||
/* */
|
||||
|
|
|
@ -2448,10 +2448,26 @@
|
|||
/*************************************************************************/
|
||||
|
||||
|
||||
AF_DEFINE_WRITING_SYSTEM_CLASS(
|
||||
af_latin_writing_system_class,
|
||||
|
||||
AF_WRITING_SYSTEM_LATIN,
|
||||
|
||||
sizeof ( AF_LatinMetricsRec ),
|
||||
|
||||
(AF_Script_InitMetricsFunc) af_latin_metrics_init,
|
||||
(AF_Script_ScaleMetricsFunc)af_latin_metrics_scale,
|
||||
(AF_Script_DoneMetricsFunc) NULL,
|
||||
|
||||
(AF_Script_InitHintsFunc) af_latin_hints_init,
|
||||
(AF_Script_ApplyHintsFunc) af_latin_hints_apply
|
||||
)
|
||||
|
||||
|
||||
/* XXX: this should probably fine tuned to differentiate better between */
|
||||
/* scripts... */
|
||||
|
||||
static const AF_Script_UniRangeRec af_latin_uniranges[] =
|
||||
static const AF_Script_UniRangeRec af_latn_uniranges[] =
|
||||
{
|
||||
AF_UNIRANGE_REC( 0x0020UL, 0x007FUL ), /* Basic Latin (no control chars) */
|
||||
AF_UNIRANGE_REC( 0x00A0UL, 0x00FFUL ), /* Latin-1 Supplement (no control chars) */
|
||||
|
@ -2485,19 +2501,14 @@
|
|||
};
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS( af_latin_script_class,
|
||||
AF_SCRIPT_LATIN,
|
||||
af_latin_uniranges,
|
||||
'o',
|
||||
AF_DEFINE_SCRIPT_CLASS(
|
||||
af_latn_script_class,
|
||||
|
||||
sizeof ( AF_LatinMetricsRec ),
|
||||
AF_SCRIPT_LATN,
|
||||
AF_WRITING_SYSTEM_LATIN,
|
||||
|
||||
(AF_Script_InitMetricsFunc) af_latin_metrics_init,
|
||||
(AF_Script_ScaleMetricsFunc)af_latin_metrics_scale,
|
||||
(AF_Script_DoneMetricsFunc) NULL,
|
||||
|
||||
(AF_Script_InitHintsFunc) af_latin_hints_init,
|
||||
(AF_Script_ApplyHintsFunc) af_latin_hints_apply
|
||||
af_latn_uniranges,
|
||||
'o'
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* Auto-fitter hinting routines for latin script (specification). */
|
||||
/* */
|
||||
/* Copyright 2003-2007, 2009, 2011-2012 by */
|
||||
/* Copyright 2003-2007, 2009, 2011-2013 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -24,10 +24,20 @@
|
|||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/* the `latin' writing system */
|
||||
|
||||
/* the latin-specific script class */
|
||||
AF_DECLARE_WRITING_SYSTEM_CLASS( af_latin_writing_system_class )
|
||||
|
||||
AF_DECLARE_SCRIPT_CLASS( af_latin_script_class )
|
||||
|
||||
/* the latin-specific script classes */
|
||||
|
||||
AF_DECLARE_SCRIPT_CLASS( af_latn_script_class ) /* XXX */
|
||||
#if 0
|
||||
AF_DECLARE_SCRIPT_CLASS( af_armn_script_class )
|
||||
AF_DECLARE_SCRIPT_CLASS( af_cyrl_script_class )
|
||||
AF_DECLARE_SCRIPT_CLASS( af_grek_script_class )
|
||||
AF_DECLARE_SCRIPT_CLASS( af_hebr_script_class )
|
||||
#endif
|
||||
|
||||
|
||||
/* constants are given with units_per_em == 2048 in mind */
|
||||
|
|
|
@ -2380,18 +2380,10 @@
|
|||
/*************************************************************************/
|
||||
|
||||
|
||||
static const AF_Script_UniRangeRec af_latin2_uniranges[] =
|
||||
{
|
||||
AF_UNIRANGE_REC( 32UL, 127UL ), /* TODO: Add new Unicode ranges here! */
|
||||
AF_UNIRANGE_REC( 160UL, 255UL ),
|
||||
AF_UNIRANGE_REC( 0UL, 0UL )
|
||||
};
|
||||
AF_DEFINE_WRITING_SYSTEM_CLASS(
|
||||
af_latin2_writing_system_class,
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS( af_latin2_script_class,
|
||||
AF_SCRIPT_LATIN2,
|
||||
af_latin2_uniranges,
|
||||
'o',
|
||||
AF_WRITING_SYSTEM_LATIN2,
|
||||
|
||||
sizeof ( AF_LatinMetricsRec ),
|
||||
|
||||
|
@ -2404,4 +2396,52 @@
|
|||
)
|
||||
|
||||
|
||||
/* 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 )
|
||||
};
|
||||
|
||||
|
||||
AF_DEFINE_SCRIPT_CLASS(
|
||||
af_ltn2_script_class,
|
||||
|
||||
AF_SCRIPT_LTN2,
|
||||
AF_WRITING_SYSTEM_LATIN2,
|
||||
|
||||
af_ltn2_uniranges,
|
||||
'o'
|
||||
)
|
||||
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* Auto-fitter hinting routines for latin script (specification). */
|
||||
/* */
|
||||
/* Copyright 2003-2007, 2012 by */
|
||||
/* Copyright 2003-2007, 2012, 2013 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -25,9 +25,21 @@
|
|||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/* the latin-specific script class */
|
||||
/* the `latin' writing system */
|
||||
|
||||
AF_DECLARE_WRITING_SYSTEM_CLASS( af_latin2_writing_system_class )
|
||||
|
||||
|
||||
/* the latin-specific script classes */
|
||||
|
||||
AF_DECLARE_SCRIPT_CLASS( af_ltn2_script_class ) /* XXX */
|
||||
#if 0
|
||||
AF_DECLARE_SCRIPT_CLASS( af_arm2_script_class )
|
||||
AF_DECLARE_SCRIPT_CLASS( af_cyr2_script_class )
|
||||
AF_DECLARE_SCRIPT_CLASS( af_grk2_script_class )
|
||||
AF_DECLARE_SCRIPT_CLASS( af_hbr2_script_class )
|
||||
#endif
|
||||
|
||||
AF_DECLARE_SCRIPT_CLASS( af_latin2_script_class )
|
||||
|
||||
/* */
|
||||
|
||||
|
|
|
@ -180,10 +180,20 @@
|
|||
|
||||
/* now load the slot image into the auto-outline and run the */
|
||||
/* automatic hinting process */
|
||||
if ( metrics->script_class->script_hints_apply )
|
||||
metrics->script_class->script_hints_apply( hints,
|
||||
&gloader->current.outline,
|
||||
metrics );
|
||||
{
|
||||
#ifdef FT_CONFIG_OPTION_PIC
|
||||
AF_FaceGlobals globals = loader->globals;
|
||||
#endif
|
||||
AF_WritingSystemClass writing_system_class =
|
||||
AF_WRITING_SYSTEM_CLASSES_GET
|
||||
[metrics->script_class->writing_system];
|
||||
|
||||
|
||||
if ( writing_system_class->script_hints_apply )
|
||||
writing_system_class->script_hints_apply( hints,
|
||||
&gloader->current.outline,
|
||||
metrics );
|
||||
}
|
||||
|
||||
/* we now need to adjust the metrics according to the change in */
|
||||
/* width/positioning that occurred during the hinting process */
|
||||
|
@ -519,33 +529,41 @@
|
|||
if ( !error )
|
||||
{
|
||||
AF_ScriptMetrics metrics;
|
||||
FT_UInt options = 0;
|
||||
FT_UInt options = AF_SCRIPT_DFLT;
|
||||
|
||||
|
||||
#ifdef FT_OPTION_AUTOFIT2
|
||||
/* XXX: undocumented hook to activate the latin2 hinter */
|
||||
/* XXX: undocumented hook to activate the latin2 writing system */
|
||||
if ( load_flags & ( 1UL << 20 ) )
|
||||
options = 2;
|
||||
options = AF_SCRIPT_LTN2;
|
||||
#endif
|
||||
|
||||
error = af_face_globals_get_metrics( loader->globals, gindex,
|
||||
options, &metrics );
|
||||
if ( !error )
|
||||
{
|
||||
#ifdef FT_CONFIG_OPTION_PIC
|
||||
AF_FaceGlobals globals = loader->globals;
|
||||
#endif
|
||||
AF_WritingSystemClass writing_system_class =
|
||||
AF_WRITING_SYSTEM_CLASSES_GET
|
||||
[metrics->script_class->writing_system];
|
||||
|
||||
|
||||
loader->metrics = metrics;
|
||||
|
||||
if ( metrics->script_class->script_metrics_scale )
|
||||
metrics->script_class->script_metrics_scale( metrics, &scaler );
|
||||
if ( writing_system_class->script_metrics_scale )
|
||||
writing_system_class->script_metrics_scale( metrics, &scaler );
|
||||
else
|
||||
metrics->scaler = scaler;
|
||||
|
||||
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
|
||||
load_flags &= ~FT_LOAD_RENDER;
|
||||
|
||||
if ( metrics->script_class->script_hints_init )
|
||||
if ( writing_system_class->script_hints_init )
|
||||
{
|
||||
error = metrics->script_class->script_hints_init( &loader->hints,
|
||||
metrics );
|
||||
error = writing_system_class->script_hints_init( &loader->hints,
|
||||
metrics );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
|
|
|
@ -100,27 +100,47 @@
|
|||
|
||||
FT_Init_Class_af_service_properties( &container->af_service_properties );
|
||||
|
||||
for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
|
||||
{
|
||||
for ( ss = 0; ss < AF_WRITING_SYSTEM_CLASSES_REC_COUNT; ss++ )
|
||||
container->af_writing_system_classes[ss] =
|
||||
&container->af_writing_system_classes_rec[ss];
|
||||
container->af_writing_system_classes
|
||||
[AF_WRITING_SYSTEM_CLASSES_COUNT - 1] = NULL;
|
||||
|
||||
for ( ss = 0; ss < AF_SCRIPT_CLASSES_REC_COUNT; ss++ )
|
||||
container->af_script_classes[ss] =
|
||||
&container->af_script_classes_rec[ss];
|
||||
}
|
||||
container->af_script_classes[AF_SCRIPT_CLASSES_COUNT - 1] = NULL;
|
||||
container->af_script_classes
|
||||
[AF_SCRIPT_CLASSES_COUNT - 1] = NULL;
|
||||
|
||||
/* add call to initialization function when you add new scripts */
|
||||
/* or writing systems */
|
||||
ss = 0;
|
||||
FT_Init_Class_af_dummy_script_class(
|
||||
FT_Init_Class_af_dummy_writing_system_class(
|
||||
&container->af_writing_system_classes_rec[ss++] );
|
||||
FT_Init_Class_af_latin_writing_system_class(
|
||||
&container->af_writing_system_classes_rec[ss++] );
|
||||
FT_Init_Class_af_cjk_writing_system_class(
|
||||
&container->af_writing_system_classes_rec[ss++] );
|
||||
FT_Init_Class_af_indic_writing_system_class(
|
||||
&container->af_writing_system_classes_rec[ss++] );
|
||||
#ifdef FT_OPTION_AUTOFIT2
|
||||
FT_Init_Class_af_latin2_writing_system_class(
|
||||
&container->af_writing_system_classes_rec[ss++] );
|
||||
#endif
|
||||
|
||||
ss = 0;
|
||||
FT_Init_Class_af_dflt_script_class(
|
||||
&container->af_script_classes_rec[ss++] );
|
||||
FT_Init_Class_af_latn_script_class(
|
||||
&container->af_script_classes_rec[ss++] );
|
||||
FT_Init_Class_af_hani_script_class(
|
||||
&container->af_script_classes_rec[ss++] );
|
||||
FT_Init_Class_af_deva_script_class(
|
||||
&container->af_script_classes_rec[ss++] );
|
||||
#ifdef FT_OPTION_AUTOFIT2
|
||||
FT_Init_Class_af_latin2_script_class(
|
||||
FT_Init_Class_af_ltn2_script_class(
|
||||
&container->af_script_classes_rec[ss++] );
|
||||
#endif
|
||||
FT_Init_Class_af_latin_script_class(
|
||||
&container->af_script_classes_rec[ss++] );
|
||||
FT_Init_Class_af_cjk_script_class(
|
||||
&container->af_script_classes_rec[ss++] );
|
||||
FT_Init_Class_af_indic_script_class(
|
||||
&container->af_script_classes_rec[ss++] );
|
||||
|
||||
FT_Init_Class_af_autofitter_interface(
|
||||
library, &container->af_autofitter_interface );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* The FreeType position independent code services for autofit module. */
|
||||
/* */
|
||||
/* Copyright 2009, 2011-2012 by */
|
||||
/* Copyright 2009, 2011-2013 by */
|
||||
/* Oran Agra and Mickey Gabel. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -27,11 +27,12 @@ FT_BEGIN_HEADER
|
|||
|
||||
#ifndef FT_CONFIG_OPTION_PIC
|
||||
|
||||
#define AF_SERVICES_GET af_services
|
||||
#define AF_SERVICE_PROPERTIES_GET af_service_properties
|
||||
#define AF_SERVICES_GET af_services
|
||||
#define AF_SERVICE_PROPERTIES_GET af_service_properties
|
||||
|
||||
#define AF_SCRIPT_CLASSES_GET af_script_classes
|
||||
#define AF_INTERFACE_GET af_autofitter_interface
|
||||
#define AF_WRITING_SYSTEM_CLASSES_GET af_writing_system_classes
|
||||
#define AF_SCRIPT_CLASSES_GET af_script_classes
|
||||
#define AF_INTERFACE_GET af_autofitter_interface
|
||||
|
||||
#else /* FT_CONFIG_OPTION_PIC */
|
||||
|
||||
|
@ -40,15 +41,20 @@ FT_BEGIN_HEADER
|
|||
|
||||
#include "aftypes.h"
|
||||
|
||||
/* increase these when you add new scripts, */
|
||||
/* and update autofit_module_class_pic_init */
|
||||
/* increase these when you add new scripts or writing systems, */
|
||||
/* and update autofit_module_class_pic_init */
|
||||
#ifdef FT_OPTION_AUTOFIT2
|
||||
#define AF_SCRIPT_CLASSES_COUNT 6
|
||||
#define AF_WRITING_SYSTEM_CLASSES_COUNT 6
|
||||
#define AF_SCRIPT_CLASSES_COUNT 6
|
||||
#else
|
||||
#define AF_SCRIPT_CLASSES_COUNT 5
|
||||
#define AF_WRITING_SYSTEM_CLASSES_COUNT 5
|
||||
#define AF_SCRIPT_CLASSES_COUNT 5
|
||||
#endif
|
||||
|
||||
#define AF_SCRIPT_CLASSES_REC_COUNT ( AF_SCRIPT_CLASSES_COUNT - 1 )
|
||||
#define AF_SCRIPT_CLASSES_REC_COUNT \
|
||||
( AF_SCRIPT_CLASSES_COUNT - 1 )
|
||||
#define AF_WRITING_SYSTEM_CLASSES_REC_COUNT \
|
||||
( AF_WRITING_SYSTEM_CLASSES_COUNT - 1 )
|
||||
|
||||
|
||||
typedef struct AFModulePIC_
|
||||
|
@ -56,8 +62,16 @@ FT_BEGIN_HEADER
|
|||
FT_ServiceDescRec* af_services;
|
||||
FT_Service_PropertiesRec af_service_properties;
|
||||
|
||||
AF_ScriptClass af_script_classes[AF_SCRIPT_CLASSES_COUNT];
|
||||
AF_ScriptClassRec af_script_classes_rec[AF_SCRIPT_CLASSES_REC_COUNT];
|
||||
AF_WritingSystemClass af_writing_system_classes
|
||||
[AF_WRITING_SYSTEM_CLASSES_COUNT];
|
||||
AF_WritingSystemClassRec af_writing_system_classes_rec
|
||||
[AF_WRITING_SYSTEM_CLASSES_REC_COUNT];
|
||||
|
||||
AF_ScriptClass af_script_classes
|
||||
[AF_SCRIPT_CLASSES_COUNT];
|
||||
AF_ScriptClassRec af_script_classes_rec
|
||||
[AF_SCRIPT_CLASSES_REC_COUNT];
|
||||
|
||||
FT_AutoHinter_InterfaceRec af_autofitter_interface;
|
||||
|
||||
} AFModulePIC;
|
||||
|
@ -71,6 +85,8 @@ FT_BEGIN_HEADER
|
|||
#define AF_SERVICE_PROPERTIES_GET \
|
||||
( GET_PIC( library )->af_service_properties )
|
||||
|
||||
#define AF_WRITING_SYSTEM_CLASSES_GET \
|
||||
( 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_INTERFACE_GET \
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* Auto-fitter types (specification only). */
|
||||
/* */
|
||||
/* Copyright 2003-2009, 2011-2012 by */
|
||||
/* Copyright 2003-2009, 2011-2013 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -20,15 +20,12 @@
|
|||
*
|
||||
* The auto-fitter is a complete rewrite of the old auto-hinter.
|
||||
* Its main feature is the ability to differentiate between different
|
||||
* scripts in order to apply language-specific rules.
|
||||
* writing systems in order to apply script-specific rules.
|
||||
*
|
||||
* The code has also been compartmentized into several entities that
|
||||
* should make algorithmic experimentation easier than with the old
|
||||
* code.
|
||||
*
|
||||
* Finally, we get rid of the Catharon license, since this code is
|
||||
* released under the FreeType one.
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
|
@ -201,52 +198,17 @@ extern void* _af_debug_hints;
|
|||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** S C R I P T S *****/
|
||||
/***** S C R I P T M E T R I C S *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* The list of known scripts. Each different script corresponds to the
|
||||
* following information:
|
||||
*
|
||||
* - A set of Unicode ranges to test whether the face supports the
|
||||
* script.
|
||||
*
|
||||
* - A specific global analyzer that will compute global metrics
|
||||
* specific to the script.
|
||||
*
|
||||
* - A specific glyph analyzer that will compute segments and
|
||||
* edges for each glyph covered by the script.
|
||||
*
|
||||
* - A specific grid-fitting algorithm that will distort the
|
||||
* scaled glyph outline according to the results of the glyph
|
||||
* analyzer.
|
||||
*
|
||||
* Note that a given analyzer and/or grid-fitting algorithm can be
|
||||
* used by more than one script.
|
||||
*/
|
||||
/* This is the main structure which combines writing systems and script */
|
||||
/* data (for a given face object, see below). */
|
||||
|
||||
typedef enum AF_Script_
|
||||
{
|
||||
AF_SCRIPT_DUMMY = 0,
|
||||
AF_SCRIPT_LATIN = 1,
|
||||
AF_SCRIPT_CJK = 2,
|
||||
AF_SCRIPT_INDIC = 3,
|
||||
#ifdef FT_OPTION_AUTOFIT2
|
||||
AF_SCRIPT_LATIN2 = 4,
|
||||
#endif
|
||||
|
||||
/* add new scripts here. Don't forget to update the list in */
|
||||
/* `afglobal.c'. */
|
||||
|
||||
AF_SCRIPT_MAX /* do not remove */
|
||||
|
||||
} AF_Script;
|
||||
|
||||
|
||||
typedef struct AF_ScriptClassRec_ const* AF_ScriptClass;
|
||||
typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals;
|
||||
typedef struct AF_WritingSystemClassRec_ const* AF_WritingSystemClass;
|
||||
typedef struct AF_ScriptClassRec_ const* AF_ScriptClass;
|
||||
typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals;
|
||||
|
||||
typedef struct AF_ScriptMetricsRec_
|
||||
{
|
||||
|
@ -284,23 +246,55 @@ extern void* _af_debug_hints;
|
|||
AF_ScriptMetrics metrics );
|
||||
|
||||
|
||||
typedef struct AF_Script_UniRangeRec_
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** W R I T I N G S Y S T E M S *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* In FreeType, a writing system consists of multiple scripts which can
|
||||
* be handled similarly *in a typographical way*; the relationship is not
|
||||
* based on history. For example, both the Greek and the unrelated
|
||||
* Armenian scripts share the same features like ascender, descender,
|
||||
* x-height, etc. Essentially, a writing system is covered by a
|
||||
* submodule of the auto-fitter; it contains
|
||||
*
|
||||
* - a specific global analyzer which computes global metrics specific to
|
||||
* the script (based on script-specific characters to identify ascender
|
||||
* height, x-height, etc.),
|
||||
*
|
||||
* - a specific glyph analyzer that computes segments and edges for each
|
||||
* glyph covered by the script,
|
||||
*
|
||||
* - a specific grid-fitting algorithm that distorts the scaled glyph
|
||||
* outline according to the results of the glyph analyzer.
|
||||
*/
|
||||
|
||||
/* The list of known writing systems. */
|
||||
typedef enum AF_WritingSystem_
|
||||
{
|
||||
FT_UInt32 first;
|
||||
FT_UInt32 last;
|
||||
AF_WRITING_SYSTEM_DUMMY = 0,
|
||||
AF_WRITING_SYSTEM_LATIN = 1,
|
||||
AF_WRITING_SYSTEM_CJK = 2,
|
||||
AF_WRITING_SYSTEM_INDIC = 3,
|
||||
#ifdef FT_OPTION_AUTOFIT2
|
||||
AF_WRITING_SYSTEM_LATIN2 = 4,
|
||||
#endif
|
||||
|
||||
} AF_Script_UniRangeRec;
|
||||
/* Add new writing systems here. Don't forget to update */
|
||||
/* the list in `afglobal.c'. */
|
||||
|
||||
#define AF_UNIRANGE_REC( a, b ) { (FT_UInt32)(a), (FT_UInt32)(b) }
|
||||
AF_WRITING_SYSTEM_MAX /* do not remove */
|
||||
|
||||
typedef const AF_Script_UniRangeRec *AF_Script_UniRange;
|
||||
} AF_WritingSystem;
|
||||
|
||||
|
||||
typedef struct AF_ScriptClassRec_
|
||||
typedef struct AF_WritingSystemClassRec_
|
||||
{
|
||||
AF_Script script;
|
||||
AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
|
||||
FT_UInt32 standard_char; /* for default width and height */
|
||||
AF_WritingSystem writing_system;
|
||||
|
||||
FT_Offset script_metrics_size;
|
||||
AF_Script_InitMetricsFunc script_metrics_init;
|
||||
|
@ -310,59 +304,166 @@ extern void* _af_debug_hints;
|
|||
AF_Script_InitHintsFunc script_hints_init;
|
||||
AF_Script_ApplyHintsFunc script_hints_apply;
|
||||
|
||||
} AF_WritingSystemClassRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** S C R I P T S *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Each script is associated with a set of Unicode ranges which gets used
|
||||
* to test whether the font face supports the script. It also references
|
||||
* the writing system it belongs to.
|
||||
*
|
||||
* We use four-letter script tags from the OpenType specification.
|
||||
*/
|
||||
|
||||
/* The list of known scripts. */
|
||||
typedef enum AF_Script_
|
||||
{
|
||||
AF_SCRIPT_DFLT = 0,
|
||||
AF_SCRIPT_LATN = 1,
|
||||
AF_SCRIPT_HANI = 2,
|
||||
AF_SCRIPT_DEVA = 3,
|
||||
#ifdef FT_OPTION_AUTOFIT2
|
||||
AF_SCRIPT_LTN2 = 4,
|
||||
#endif
|
||||
|
||||
/* Add new scripts here. Don't forget to update */
|
||||
/* the list in `afglobal.c'. */
|
||||
|
||||
AF_SCRIPT_MAX /* do not remove */
|
||||
|
||||
} AF_Script;
|
||||
|
||||
|
||||
typedef struct AF_Script_UniRangeRec_
|
||||
{
|
||||
FT_UInt32 first;
|
||||
FT_UInt32 last;
|
||||
|
||||
} AF_Script_UniRangeRec;
|
||||
|
||||
#define AF_UNIRANGE_REC( a, b ) { (FT_UInt32)(a), (FT_UInt32)(b) }
|
||||
|
||||
typedef const AF_Script_UniRangeRec* AF_Script_UniRange;
|
||||
|
||||
|
||||
typedef struct AF_ScriptClassRec_
|
||||
{
|
||||
AF_Script script;
|
||||
AF_WritingSystem writing_system;
|
||||
|
||||
AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
|
||||
FT_UInt32 standard_char; /* for default width and height */
|
||||
|
||||
} AF_ScriptClassRec;
|
||||
|
||||
|
||||
/* Declare and define vtables for classes */
|
||||
#ifndef FT_CONFIG_OPTION_PIC
|
||||
|
||||
#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \
|
||||
FT_CALLBACK_TABLE const AF_WritingSystemClassRec \
|
||||
writing_system_class;
|
||||
|
||||
#define AF_DEFINE_WRITING_SYSTEM_CLASS( \
|
||||
writing_system_class, \
|
||||
system, \
|
||||
m_size, \
|
||||
m_init, \
|
||||
m_scale, \
|
||||
m_done, \
|
||||
h_init, \
|
||||
h_apply ) \
|
||||
FT_CALLBACK_TABLE_DEF \
|
||||
const AF_WritingSystemClassRec writing_system_class = \
|
||||
{ \
|
||||
system, \
|
||||
\
|
||||
m_size, \
|
||||
\
|
||||
m_init, \
|
||||
m_scale, \
|
||||
m_done, \
|
||||
\
|
||||
h_init, \
|
||||
h_apply \
|
||||
};
|
||||
|
||||
|
||||
#define AF_DECLARE_SCRIPT_CLASS( script_class ) \
|
||||
FT_CALLBACK_TABLE const AF_ScriptClassRec \
|
||||
script_class;
|
||||
|
||||
#define AF_DEFINE_SCRIPT_CLASS( script_class, script_, ranges, def_char, \
|
||||
m_size, \
|
||||
m_init, m_scale, m_done, h_init, h_apply ) \
|
||||
FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec script_class = \
|
||||
{ \
|
||||
script_, \
|
||||
ranges, \
|
||||
def_char, \
|
||||
\
|
||||
m_size, \
|
||||
\
|
||||
m_init, \
|
||||
m_scale, \
|
||||
m_done, \
|
||||
\
|
||||
h_init, \
|
||||
h_apply \
|
||||
#define AF_DEFINE_SCRIPT_CLASS( \
|
||||
script_class, \
|
||||
script_, \
|
||||
writing_system_, \
|
||||
ranges, \
|
||||
std_char ) \
|
||||
FT_CALLBACK_TABLE_DEF \
|
||||
const AF_ScriptClassRec script_class = \
|
||||
{ \
|
||||
script_, \
|
||||
writing_system_, \
|
||||
ranges, \
|
||||
std_char \
|
||||
};
|
||||
|
||||
#else /* FT_CONFIG_OPTION_PIC */
|
||||
|
||||
#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \
|
||||
FT_LOCAL( void ) \
|
||||
FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac );
|
||||
|
||||
#define AF_DEFINE_WRITING_SYSTEM_CLASS( \
|
||||
writing_system_class, \
|
||||
system, \
|
||||
m_size, \
|
||||
m_init, \
|
||||
m_scale, \
|
||||
m_done, \
|
||||
h_init, \
|
||||
h_apply ) \
|
||||
FT_LOCAL_DEF( void ) \
|
||||
FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac ) \
|
||||
{ \
|
||||
ac->writing_system = system; \
|
||||
\
|
||||
ac->script_metrics_size = m_size; \
|
||||
\
|
||||
ac->script_metrics_init = m_init; \
|
||||
ac->script_metrics_scale = m_scale; \
|
||||
ac->script_metrics_done = m_done; \
|
||||
\
|
||||
ac->script_hints_init = h_init; \
|
||||
ac->script_hints_apply = h_apply; \
|
||||
}
|
||||
|
||||
|
||||
#define AF_DECLARE_SCRIPT_CLASS( script_class ) \
|
||||
FT_LOCAL( void ) \
|
||||
FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac );
|
||||
|
||||
#define AF_DEFINE_SCRIPT_CLASS( script_class, script_, ranges, def_char, \
|
||||
m_size, \
|
||||
m_init, m_scale, m_done, h_init, h_apply ) \
|
||||
FT_LOCAL_DEF( void ) \
|
||||
FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \
|
||||
{ \
|
||||
ac->script = script_; \
|
||||
ac->script_uni_ranges = ranges; \
|
||||
ac->default_char = def_char; \
|
||||
\
|
||||
ac->script_metrics_size = m_size; \
|
||||
\
|
||||
ac->script_metrics_init = m_init; \
|
||||
ac->script_metrics_scale = m_scale; \
|
||||
ac->script_metrics_done = m_done; \
|
||||
\
|
||||
ac->script_hints_init = h_init; \
|
||||
ac->script_hints_apply = h_apply; \
|
||||
#define AF_DEFINE_SCRIPT_CLASS( \
|
||||
script_class, \
|
||||
script_, \
|
||||
writing_system_, \
|
||||
ranges, \
|
||||
std_char ) \
|
||||
FT_LOCAL_DEF( void ) \
|
||||
FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \
|
||||
{ \
|
||||
ac->script = script_; \
|
||||
ac->writing_system = writing_system_; \
|
||||
ac->script_uni_ranges = ranges; \
|
||||
ac->standard_char = std_char; \
|
||||
}
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_PIC */
|
||||
|
|
Loading…
Reference in New Issue