From 17af586e0589df2c0bded15c13b5da24873426ab Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sat, 28 Dec 2013 10:33:01 +0100 Subject: [PATCH] [autofit] Add wrapper function for `FT_Get_Char_Index'. Yet-to-come changes will provide HarfBuzz functionality for the new function. * src/autofit/hbshim.c (af_get_char_index): New function. * src/autofit/hbshim.h: Updated. * src/autofit/afcjk.c (af_cjk_metrics_init_widths, af_cjk_metrics_init_blues, af_cjk_metrics_check_digits): Updated. * src/autofit/aflatin.c (af_latin_metrics_init_widths, af_latin_metrics_init_blues, af_latin_metrics_check_digits): Updated. --- ChangeLog | 17 +++++++++++++++++ src/autofit/afcjk.c | 7 ++++--- src/autofit/aflatin.c | 7 ++++--- src/autofit/hbshim.c | 38 +++++++++++++++++++++++++++++++++++++- src/autofit/hbshim.h | 12 +++++++++++- 5 files changed, 73 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 041ccf029..dd0a75e04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2013-12-28 Werner Lemberg + + [autofit] Add wrapper function for `FT_Get_Char_Index'. + + Yet-to-come changes will provide HarfBuzz functionality for the new + function. + + * src/autofit/hbshim.c (af_get_char_index): New function. + * src/autofit/hbshim.h: Updated. + + * src/autofit/afcjk.c (af_cjk_metrics_init_widths, + af_cjk_metrics_init_blues, af_cjk_metrics_check_digits): Updated. + + * src/autofit/aflatin.c (af_latin_metrics_init_widths, + af_latin_metrics_init_blues, af_latin_metrics_check_digits): + Updated. + 2013-12-28 Werner Lemberg [autofit] Use `global' HarfBuzz font object. diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c index 4cc01b6e1..f27e72a1f 100644 --- a/src/autofit/afcjk.c +++ b/src/autofit/afcjk.c @@ -101,7 +101,8 @@ [style_class->script]; - glyph_index = FT_Get_Char_Index( face, script_class->standard_char ); + glyph_index = af_get_char_index( &metrics->root, + script_class->standard_char ); if ( glyph_index == 0 ) goto Exit; @@ -297,7 +298,7 @@ GET_UTF8_CHAR( ch, p ); /* load the character in the face -- skip unknown or empty ones */ - glyph_index = FT_Get_Char_Index( face, ch ); + glyph_index = af_get_char_index( &metrics->root, ch ); if ( glyph_index == 0 ) { FT_TRACE5(( " U+%04lX unavailable\n", ch )); @@ -479,7 +480,7 @@ FT_UInt glyph_index; - glyph_index = FT_Get_Char_Index( face, i ); + glyph_index = af_get_char_index( &metrics->root, i ); if ( glyph_index == 0 ) continue; diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index 518ceeb5d..0b4709a17 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -88,7 +88,8 @@ [style_class->script]; - glyph_index = FT_Get_Char_Index( face, script_class->standard_char ); + glyph_index = af_get_char_index( &metrics->root, + script_class->standard_char ); if ( glyph_index == 0 ) goto Exit; @@ -296,7 +297,7 @@ GET_UTF8_CHAR( ch, p ); /* load the character in the face -- skip unknown or empty ones */ - glyph_index = FT_Get_Char_Index( face, ch ); + glyph_index = af_get_char_index( &metrics->root, ch ); if ( glyph_index == 0 ) { FT_TRACE5(( " U+%04lX unavailable\n", ch )); @@ -745,7 +746,7 @@ FT_UInt glyph_index; - glyph_index = FT_Get_Char_Index( face, i ); + glyph_index = af_get_char_index( &metrics->root, i ); if ( glyph_index == 0 ) continue; diff --git a/src/autofit/hbshim.c b/src/autofit/hbshim.c index 22adcaf01..e9b93a229 100644 --- a/src/autofit/hbshim.c +++ b/src/autofit/hbshim.c @@ -267,6 +267,22 @@ } + FT_UInt + af_get_char_index( AF_StyleMetrics metrics, + FT_ULong charcode ) + { + FT_Face face; + + + if ( !metrics ) + return FT_THROW( Invalid_Argument ); + + face = metrics->globals->face; + + return FT_Get_Char_Index( face, charcode ); + } + + #if 0 /* to be always excluded */ COVERAGE(nalt, 'n', 'a', 'l', 't'); /* Alternate Annotation Forms (?) */ @@ -274,7 +290,27 @@ /* COVERAGE(ruby, 'r', 'u', 'b', 'y') */ /* (only for Japanese) */ #endif -#endif /* FT_CONFIG_OPTION_USE_HARFBUZZ */ + +#else /* !FT_CONFIG_OPTION_USE_HARDBUZZ */ + + + FT_UInt + af_get_char_index( AF_StyleMetrics metrics, + FT_ULong charcode ) + { + FT_Face face; + + + if ( !metrics ) + return FT_THROW( Invalid_Argument ); + + face = metrics->globals->face; + + return FT_Get_Char_Index( face, charcode ); + } + + +#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ */ /* END */ diff --git a/src/autofit/hbshim.h b/src/autofit/hbshim.h index 09df68098..915ca7535 100644 --- a/src/autofit/hbshim.h +++ b/src/autofit/hbshim.h @@ -38,12 +38,22 @@ FT_BEGIN_HEADER AF_StyleClass style_class, FT_Byte* gstyles ); + FT_UInt + af_get_char_index( AF_StyleMetrics metrics, + FT_ULong charcode ); + /* */ FT_END_HEADER -#endif /* FT_CONFIG_OPTION_USE_HARFBUZZ */ +#else /* !FT_CONFIG_OPTION_USE_HARFBUZZ */ + + FT_UInt + af_get_char_index( AF_StyleMetrics metrics, + FT_ULong charcode ); + +#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ */ #endif /* __HBSHIM_H__ */