From f0c476760489129960e98216d70f221d9922339a Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sat, 5 Jul 2014 00:32:39 +0200 Subject: [PATCH] Fix thinko in coverage handling of TTCs. s/TA_sfnt_adjust_master_coverage/TA_sfnt_adjust_coverage/; this function has to be executed for all `glyf' tables so that the fallback script gets properly adjusted. Also slightly improve debugging output. --- lib/ta.h | 10 ++++++---- lib/taglobal.c | 16 ++++++++++++---- lib/taglyf.c | 34 +++++++++++++++++----------------- lib/ttfautohint.c | 3 +-- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/lib/ta.h b/lib/ta.h index 2f82f49..49a9a42 100644 --- a/lib/ta.h +++ b/lib/ta.h @@ -128,9 +128,11 @@ typedef struct glyf_Data_ FT_UShort num_glyphs; GLYPH* glyphs; - /* this index gives the `master' globals for a `glyf' table; */ + /* this field gives the `master' globals for a `glyf' table; */ /* see function `TA_sfnt_handle_coverage' */ TA_FaceGlobals master_globals; + /* for coverage bookkeeping */ + FT_Bool adjusted; /* if a `glyf' table gets used in more than one subfont, */ /* so do `cvt', `fpgm', and `prep' tables: */ @@ -314,9 +316,9 @@ TA_sfnt_create_glyf_data(SFNT* sfnt, FT_Error TA_sfnt_handle_coverage(SFNT* sfnt, FONT* font); -FT_Bool -TA_sfnt_adjust_master_coverage(SFNT* sfnt, - FONT* font); +void +TA_sfnt_adjust_coverage(SFNT* sfnt, + FONT* font); #if 0 void TA_sfnt_copy_master_coverage(SFNT* sfnt, diff --git a/lib/taglobal.c b/lib/taglobal.c index 64e82a2..10cf521 100644 --- a/lib/taglobal.c +++ b/lib/taglobal.c @@ -344,10 +344,18 @@ Exit: #ifdef TA_DEBUG - TA_LOG_GLOBAL(("\n" - "style coverage\n" - "==============\n" - "\n")); + if (face->num_faces > 1) + TA_LOG_GLOBAL(("\n" + "style coverage (subfont %d, glyf table index %d)\n" + "================================================\n" + "\n", + face->face_index, + globals->font->sfnts[face->face_index].glyf_idx)); + else + TA_LOG_GLOBAL(("\n" + "style coverage\n" + "==============\n" + "\n")); for (ss = 0; ta_style_classes[ss]; ss++) { diff --git a/lib/taglyf.c b/lib/taglyf.c index ed44a0d..bd7169c 100644 --- a/lib/taglyf.c +++ b/lib/taglyf.c @@ -1212,10 +1212,8 @@ TA_sfnt_create_glyf_data(SFNT* sfnt, * relies on the `cmap' table and OpenType features to get style coverage * data. In TTCs, subfonts normally share the same `glyf' table but use * different `cmap's and OpenType features (in `GSUB' and `GPOS' tables). - * Covering the most common situation, namely a single `glyf' table and - * multiple `cmap's and OpenType features, ttfautohint merges coverage data - * for the first subfont's `glyf' table with all other subfonts that also - * use this very `glyf' table. + * To handle this gracefully, ttfautohint collects (and merges) the coverage + * information in the `glyf_Data' structure. */ FT_Error @@ -1289,21 +1287,18 @@ Exit: } -FT_Bool -TA_sfnt_adjust_master_coverage(SFNT* sfnt, - FONT* font) +void +TA_sfnt_adjust_coverage(SFNT* sfnt, + FONT* font) { SFNT_Table* glyf_table = &font->tables[sfnt->glyf_idx]; glyf_Data* data = (glyf_Data*)glyf_table->data; - FT_Face face = sfnt->face; - TA_FaceGlobals master_globals = data->master_globals; - TA_FaceGlobals curr_globals = (TA_FaceGlobals)face->autohint.data; /* use fallback style for uncovered glyphs */ - if (master_globals == curr_globals) + if (!data->adjusted) { FT_Long nn; FT_Byte* gstyles = master_globals->glyph_styles; @@ -1323,9 +1318,16 @@ TA_sfnt_adjust_master_coverage(SFNT* sfnt, #ifdef TA_DEBUG - TA_LOG_GLOBAL(("\n" - "using fallback style `%s' for unassigned glyphs:\n", - ta_style_names[master_globals->font->fallback_style])); + if (sfnt->face->num_faces > 1) + TA_LOG_GLOBAL(("\n" + "using fallback style `%s' for unassigned glyphs" + " (glyf table index %d):\n", + ta_style_names[master_globals->font->fallback_style], + sfnt->glyf_idx)); + else + TA_LOG_GLOBAL(("\n" + "using fallback style `%s' for unassigned glyphs:\n", + ta_style_names[master_globals->font->fallback_style])); count = 0; @@ -1351,10 +1353,8 @@ TA_sfnt_adjust_master_coverage(SFNT* sfnt, #endif /* TA_DEBUG */ - return 1; /* master coverage adjusted */ + data->adjusted = 1; } - else - return 0; } diff --git a/lib/ttfautohint.c b/lib/ttfautohint.c index a116ab5..36b4bbd 100644 --- a/lib/ttfautohint.c +++ b/lib/ttfautohint.c @@ -563,8 +563,7 @@ No_check: SFNT* sfnt = &font->sfnts[i]; - if (TA_sfnt_adjust_master_coverage(sfnt, font)) - break; + TA_sfnt_adjust_coverage(sfnt, font); } } -- 2.11.4.GIT