From 37c401ac0a62b2abb0a12df87881fa3f05159582 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler Date: Mon, 2 Nov 2015 09:32:26 +0100 Subject: [PATCH] [autofit] Add functions to get standard widths for writing systems. We need the computed standard horizontal and vertical widths for the emboldening calculation. This method provides a convenient way to extract it from writing-system-specific metrics structures, which all script definitions must implement. * src/autofit/aftypes.h (AF_WritingSystem_GetStdWidthsFunc): New function type. (AF_WritingSystemClassRec): New member `style_metrics_getstdw'. (AF_DEFINE_WRITING_SYSTEM_CLASS): Updated. * src/autofit/afcjk.c (af_cjk_get_standard_width): New function. (af_cjk_writing_system_class): Updated. * src/autofit/afdummy.c (af_dummy_writing_system_class): Updated. * src/autofit/afindic.c (af_cjk_get_standard_width): New function. (af_indic_writing_system_class): Updated. * src/autofit/aflatin.c (af_latin_get_standard_width): New function. (af_indic_writing_system_class): Updated. * src/autofit/aflatin.c (af_latin_get_standard_width): New function. (af_indic_writing_system_class): Updated. --- ChangeLog | 24 ++++++++++++++++++++++++ src/autofit/afcjk.c | 18 ++++++++++++++++++ src/autofit/afdummy.c | 1 + src/autofit/afindic.c | 18 ++++++++++++++++++ src/autofit/aflatin.c | 17 +++++++++++++++++ src/autofit/aflatin2.c | 17 +++++++++++++++++ src/autofit/aftypes.h | 23 ++++++++++++++++------- 7 files changed, 111 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 697167bcf..c380fb570 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2015-11-02 Nikolaus Waxweiler + + [autofit] Add functions to get standard widths for writing systems. + + We need the computed standard horizontal and vertical widths for the + emboldening calculation. This method provides a convenient way to + extract it from writing-system-specific metrics structures, which + all script definitions must implement. + + * src/autofit/aftypes.h (AF_WritingSystem_GetStdWidthsFunc): New + function type. + (AF_WritingSystemClassRec): New member `style_metrics_getstdw'. + (AF_DEFINE_WRITING_SYSTEM_CLASS): Updated. + + * src/autofit/afcjk.c (af_cjk_get_standard_width): New function. + (af_cjk_writing_system_class): Updated. + * src/autofit/afdummy.c (af_dummy_writing_system_class): Updated. + * src/autofit/afindic.c (af_cjk_get_standard_width): New function. + (af_indic_writing_system_class): Updated. + * src/autofit/aflatin.c (af_latin_get_standard_width): New function. + (af_indic_writing_system_class): Updated. + * src/autofit/aflatin.c (af_latin_get_standard_width): New function. + (af_indic_writing_system_class): Updated. + 2015-11-02 Nikolaus Waxweiler [autofit] Extend `AF_FaceGlobalsRec' to hold emboldening data. diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c index 0ade4be40..792950dc9 100644 --- a/src/autofit/afcjk.c +++ b/src/autofit/afcjk.c @@ -688,6 +688,22 @@ } + /* Extract standard_width from writing system/script specific */ + /* metrics class. */ + + FT_LOCAL_DEF( void ) + af_cjk_get_standard_widths( AF_CJKMetrics metrics, + FT_Pos* stdHW, + FT_Pos* stdVW ) + { + if ( stdHW ) + *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width; + + if ( stdVW ) + *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width; + } + + /*************************************************************************/ /*************************************************************************/ /***** *****/ @@ -2280,6 +2296,7 @@ (AF_WritingSystem_InitMetricsFunc) af_cjk_metrics_init, (AF_WritingSystem_ScaleMetricsFunc)af_cjk_metrics_scale, (AF_WritingSystem_DoneMetricsFunc) NULL, + (AF_WritingSystem_GetStdWidthsFunc)af_cjk_get_standard_widths, (AF_WritingSystem_InitHintsFunc) af_cjk_hints_init, (AF_WritingSystem_ApplyHintsFunc) af_cjk_hints_apply @@ -2299,6 +2316,7 @@ (AF_WritingSystem_InitMetricsFunc) NULL, (AF_WritingSystem_ScaleMetricsFunc)NULL, (AF_WritingSystem_DoneMetricsFunc) NULL, + (AF_WritingSystem_GetStdWidthsFunc)NULL, (AF_WritingSystem_InitHintsFunc) NULL, (AF_WritingSystem_ApplyHintsFunc) NULL diff --git a/src/autofit/afdummy.c b/src/autofit/afdummy.c index 18dd301d1..9142c78c2 100644 --- a/src/autofit/afdummy.c +++ b/src/autofit/afdummy.c @@ -65,6 +65,7 @@ (AF_WritingSystem_InitMetricsFunc) NULL, (AF_WritingSystem_ScaleMetricsFunc)NULL, (AF_WritingSystem_DoneMetricsFunc) NULL, + (AF_WritingSystem_GetStdWidthsFunc)NULL, (AF_WritingSystem_InitHintsFunc) af_dummy_hints_init, (AF_WritingSystem_ApplyHintsFunc) af_dummy_hints_apply diff --git a/src/autofit/afindic.c b/src/autofit/afindic.c index 05b6bdd88..59b14d7e0 100644 --- a/src/autofit/afindic.c +++ b/src/autofit/afindic.c @@ -89,6 +89,22 @@ } + /* Extract standard_width from writing system/script specific */ + /* metrics class. */ + + static void + af_indic_get_standard_widths( AF_CJKMetrics metrics, + FT_Pos* stdHW, + FT_Pos* stdVW ) + { + if ( stdHW ) + *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width; + + if ( stdVW ) + *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width; + } + + /*************************************************************************/ /*************************************************************************/ /***** *****/ @@ -108,6 +124,7 @@ (AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init, (AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale, (AF_WritingSystem_DoneMetricsFunc) NULL, + (AF_WritingSystem_GetStdWidthsFunc)af_indic_get_standard_widths, (AF_WritingSystem_InitHintsFunc) af_indic_hints_init, (AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply @@ -127,6 +144,7 @@ (AF_WritingSystem_InitMetricsFunc) NULL, (AF_WritingSystem_ScaleMetricsFunc)NULL, (AF_WritingSystem_DoneMetricsFunc) NULL, + (AF_WritingSystem_GetStdWidthsFunc)NULL, (AF_WritingSystem_InitHintsFunc) NULL, (AF_WritingSystem_ApplyHintsFunc) NULL diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index 363f72114..5645aaf04 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -1149,6 +1149,22 @@ } + /* Extract standard_width from writing system/script specific */ + /* metrics class. */ + + FT_LOCAL_DEF( void ) + af_latin_get_standard_widths( AF_LatinMetrics metrics, + FT_Pos* stdHW, + FT_Pos* stdVW ) + { + if ( stdHW ) + *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width; + + if ( stdVW ) + *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width; + } + + /*************************************************************************/ /*************************************************************************/ /***** *****/ @@ -2944,6 +2960,7 @@ (AF_WritingSystem_InitMetricsFunc) af_latin_metrics_init, (AF_WritingSystem_ScaleMetricsFunc)af_latin_metrics_scale, (AF_WritingSystem_DoneMetricsFunc) NULL, + (AF_WritingSystem_GetStdWidthsFunc)af_latin_get_standard_widths, (AF_WritingSystem_InitHintsFunc) af_latin_hints_init, (AF_WritingSystem_ApplyHintsFunc) af_latin_hints_apply diff --git a/src/autofit/aflatin2.c b/src/autofit/aflatin2.c index 0380ffc04..2fb7d1d35 100644 --- a/src/autofit/aflatin2.c +++ b/src/autofit/aflatin2.c @@ -693,6 +693,22 @@ } + /* Extract standard_width from writing system/script specific */ + /* metrics class. */ + + FT_LOCAL_DEF( void ) + af_latin2_get_standard_widths( AF_LatinMetrics metrics, + FT_Pos* stdHW, + FT_Pos* stdVW ) + { + if ( stdHW ) + *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width; + + if ( stdVW ) + *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width; + } + + /*************************************************************************/ /*************************************************************************/ /***** *****/ @@ -2392,6 +2408,7 @@ (AF_WritingSystem_InitMetricsFunc) af_latin2_metrics_init, (AF_WritingSystem_ScaleMetricsFunc)af_latin2_metrics_scale, (AF_WritingSystem_DoneMetricsFunc) NULL, + (AF_WritingSystem_GetStdWidthsFunc)af_latin2_get_standard_widths, (AF_WritingSystem_InitHintsFunc) af_latin2_hints_init, (AF_WritingSystem_ApplyHintsFunc) af_latin2_hints_apply diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h index 43b38006c..cbe8bc23b 100644 --- a/src/autofit/aftypes.h +++ b/src/autofit/aftypes.h @@ -211,6 +211,11 @@ extern void* _af_debug_hints; typedef void (*AF_WritingSystem_DoneMetricsFunc)( AF_StyleMetrics metrics ); + typedef void + (*AF_WritingSystem_GetStdWidthsFunc)( AF_StyleMetrics metrics, + FT_Pos* stdHW, + FT_Pos* stdVW ); + typedef FT_Error (*AF_WritingSystem_InitHintsFunc)( AF_GlyphHints hints, @@ -276,6 +281,7 @@ extern void* _af_debug_hints; AF_WritingSystem_InitMetricsFunc style_metrics_init; AF_WritingSystem_ScaleMetricsFunc style_metrics_scale; AF_WritingSystem_DoneMetricsFunc style_metrics_done; + AF_WritingSystem_GetStdWidthsFunc style_metrics_getstdw; AF_WritingSystem_InitHintsFunc style_hints_init; AF_WritingSystem_ApplyHintsFunc style_hints_apply; @@ -489,6 +495,7 @@ extern void* _af_debug_hints; m_init, \ m_scale, \ m_done, \ + m_stdw, \ h_init, \ h_apply ) \ FT_CALLBACK_TABLE_DEF \ @@ -501,6 +508,7 @@ extern void* _af_debug_hints; m_init, \ m_scale, \ m_done, \ + m_stdw, \ \ h_init, \ h_apply \ @@ -570,16 +578,17 @@ extern void* _af_debug_hints; FT_LOCAL_DEF( void ) \ FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac ) \ { \ - ac->writing_system = system; \ + ac->writing_system = system; \ \ - ac->style_metrics_size = m_size; \ + ac->style_metrics_size = m_size; \ \ - ac->style_metrics_init = m_init; \ - ac->style_metrics_scale = m_scale; \ - ac->style_metrics_done = m_done; \ + ac->style_metrics_init = m_init; \ + ac->style_metrics_scale = m_scale; \ + ac->style_metrics_done = m_done; \ + ac->style_metrics_getstdw = m_stdw; \ \ - ac->style_hints_init = h_init; \ - ac->style_hints_apply = h_apply; \ + ac->style_hints_init = h_init; \ + ac->style_hints_apply = h_apply; \ }