[autofit] Fix handling of default script.

Patch taken from ttfautohint, commit
071ae2c00e0d67f9d19418f4fade1c23d27dc185.

There were two bugs.

  - We now use non-standard script tags like `khms' for special
    purposes.  However, HarfBuzz maps such tags to `DFLT', and
    without this commit the associated lookups were incorrectly
    assigned to the non-standard tags.

  - Let's assume we have a Bengali font, and the font's `DFLT'
    script tag handles the necessary lookups for Bengali, too.
    Without this commit, the `DFLT' lookups were assigned to
    ttfautohint's default script (usually `latn') before the
    standard lookups for Bengali were handled.

    We now have the following order while searching for covered
    glyph indices.

      special features of scripts (e.g. `sups' for Cyrillic)
      Unicode mappings of scripts
      remaining features of scripts (especially important for Indic
        scripts)
      default features of default script

* src/autofit/afshaper.c, src/autofit/afshaper.h
(af_shaper_get_coverage): Add boolean parameter to indicate default
script.
Update all callers.

* src/autofit/afglobal.c (af_face_globals_compute_style_coverage):
Fix search order for coverages.
This commit is contained in:
Werner Lemberg 2016-01-19 19:33:57 +01:00
parent fc11af1ea2
commit ec776596ce
4 changed files with 54 additions and 11 deletions

View File

@ -1,3 +1,40 @@
2016-01-19 Werner Lemberg <wl@gnu.org>
[autofit] Fix handling of default script.
Patch taken from ttfautohint, commit
071ae2c00e0d67f9d19418f4fade1c23d27dc185.
There were two bugs.
- We now use non-standard script tags like `khms' for special
purposes. However, HarfBuzz maps such tags to `DFLT', and
without this commit the associated lookups were incorrectly
assigned to the non-standard tags.
- Let's assume we have a Bengali font, and the font's `DFLT'
script tag handles the necessary lookups for Bengali, too.
Without this commit, the `DFLT' lookups were assigned to
ttfautohint's default script (usually `latn') before the
standard lookups for Bengali were handled.
We now have the following order while searching for covered
glyph indices.
special features of scripts (e.g. `sups' for Cyrillic)
Unicode mappings of scripts
remaining features of scripts (especially important for Indic
scripts)
default features of default script
* src/autofit/afshaper.c, src/autofit/afshaper.h
(af_shaper_get_coverage): Add boolean parameter to indicate default
script.
Update all callers.
* src/autofit/afglobal.c (af_face_globals_compute_style_coverage):
Fix search order for coverages.
2016-01-19 Werner Lemberg <wl@gnu.org>
Various minor clang fixes.

View File

@ -241,23 +241,23 @@
else
{
/* get glyphs not directly addressable by cmap */
af_shaper_get_coverage( globals, style_class, gstyles );
af_shaper_get_coverage( globals, style_class, gstyles, 0 );
}
}
/* handle the default OpenType features of the default script ... */
af_shaper_get_coverage( globals, AF_STYLE_CLASSES_GET[dflt], gstyles );
/* ... and the remaining default OpenType features */
/* handle the remaining default OpenType features ... */
for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
{
AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss];
if ( ss != dflt && style_class->coverage == AF_COVERAGE_DEFAULT )
af_shaper_get_coverage( globals, style_class, gstyles );
if ( style_class->coverage == AF_COVERAGE_DEFAULT )
af_shaper_get_coverage( globals, style_class, gstyles, 0 );
}
/* ... and finally the default OpenType features of the default script */
af_shaper_get_coverage( globals, AF_STYLE_CLASSES_GET[dflt], gstyles, 1 );
/* mark ASCII digits */
for ( i = 0x30; i <= 0x39; i++ )
{

View File

@ -98,7 +98,8 @@
FT_Error
af_shaper_get_coverage( AF_FaceGlobals globals,
AF_StyleClass style_class,
FT_UShort* gstyles )
FT_UShort* gstyles,
FT_Bool default_script )
{
hb_face_t* face;
@ -143,8 +144,7 @@
/* `hb_ot_tags_from_script' usually returns HB_OT_TAG_DEFAULT_SCRIPT */
/* as the second tag. We change that to HB_TAG_NONE except for the */
/* default script. */
if ( style_class->script == globals->module->default_script &&
style_class->coverage == AF_COVERAGE_DEFAULT )
if ( default_script )
{
if ( script_tags[0] == HB_TAG_NONE )
script_tags[0] = HB_OT_TAG_DEFAULT_SCRIPT;
@ -158,6 +158,11 @@
}
else
{
/* we use non-standard tags like `khms' for special purposes; */
/* HarfBuzz maps them to `DFLT', which we don't want to handle here */
if ( script_tags[0] == HB_OT_TAG_DEFAULT_SCRIPT )
goto Exit;
if ( script_tags[1] == HB_OT_TAG_DEFAULT_SCRIPT )
script_tags[1] = HB_TAG_NONE;
}

View File

@ -38,7 +38,8 @@ FT_BEGIN_HEADER
FT_Error
af_shaper_get_coverage( AF_FaceGlobals globals,
AF_StyleClass style_class,
FT_UShort* gstyles );
FT_UShort* gstyles,
FT_Bool default_script );
void*