diff options
Diffstat (limited to 'src/autofit/aftypes.h')
-rw-r--r-- | src/autofit/aftypes.h | 287 |
1 files changed, 195 insertions, 92 deletions
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h index 9acd7ad..cda1f89 100644 --- a/src/autofit/aftypes.h +++ b/src/autofit/aftypes.h @@ -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. - * *************************************************************************/ @@ -42,6 +39,8 @@ #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H +#include "afblue.h" + FT_BEGIN_HEADER @@ -201,56 +200,21 @@ 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. - */ - - 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; + /* This is the main structure which combines writing systems and script */ + /* data (for a given face object, see below). */ - - 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_ { - AF_ScriptClass clazz; + AF_ScriptClass script_class; AF_ScalerRec scaler; FT_Bool digits_have_same_width; @@ -284,23 +248,54 @@ 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. + */ + +#define __AFWRTSYS_H__ /* don't load header files */ +#undef WRITING_SYSTEM +#define WRITING_SYSTEM( ws, WS ) \ + AF_WRITING_SYSTEM_ ## WS, + + /* The list of known writing systems. */ + typedef enum AF_WritingSystem_ { - FT_UInt32 first; - FT_UInt32 last; - } AF_Script_UniRangeRec; +#include "afwrtsys.h" -#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; +#undef __AFWRTSYS_H__ - 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 +305,167 @@ 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. + */ + +#undef SCRIPT +#define SCRIPT( s, S, d ) \ + AF_SCRIPT_ ## S, + + /* The list of known scripts. */ + typedef enum AF_Script_ + { + +#include "afscript.h" + + 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_Blue_Stringset blue_stringset; + 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_, \ + blue_stringset_, \ + writing_system_, \ + ranges, \ + std_char ) \ + FT_CALLBACK_TABLE_DEF \ + const AF_ScriptClassRec script_class = \ + { \ + script_, \ + blue_stringset_, \ + 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_, \ + blue_string_set_, \ + writing_system_, \ + 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_uni_ranges = ranges; \ + ac->standard_char = std_char; \ } #endif /* FT_CONFIG_OPTION_PIC */ |