Bug 1711947 - Update glyph properties during AAT substitutions so that mark zeroing works as expected. r=RyanVM

Cherry-pick of the following upstream commits:
[aat] Update glyph properties from GDEF if available when doing a replacement.
[aat] If shaping via morx, don't adjust mark positioning when zeroing widths.

https://github.com/harfbuzz/harfbuzz/pull/2968

Differential Revision: https://phabricator.services.mozilla.com/D115542
This commit is contained in:
jkew 2021-05-19 22:13:13 +00:00
Родитель ba711ff95b
Коммит 7cbbbc1426
6 изменённых файлов: 38 добавлений и 6 удалений

Просмотреть файл

@ -30,6 +30,9 @@
#include "hb-aat-layout.hh"
#include "hb-open-type.hh"
namespace OT {
struct GDEF;
};
namespace AAT {
@ -863,6 +866,7 @@ struct hb_aat_apply_context_t :
hb_buffer_t *buffer;
hb_sanitize_context_t sanitizer;
const ankr *ankr_table;
const OT::GDEF *gdef_table;
/* Unused. For debug tracing only. */
unsigned int lookup_index;

Просмотреть файл

@ -30,6 +30,7 @@
#include "hb-open-type.hh"
#include "hb-aat-layout-common.hh"
#include "hb-ot-layout-common.hh"
#include "hb-ot-layout-gdef-table.hh"
#include "hb-aat-map.hh"
/*
@ -215,7 +216,9 @@ struct ContextualSubtable
hb_aat_apply_context_t *c_) :
ret (false),
c (c_),
gdef (*c->gdef_table),
mark_set (false),
has_glyph_classes (gdef.has_glyph_classes ()),
mark (0),
table (table_),
subs (table+table->substitutionTables) {}
@ -263,6 +266,9 @@ struct ContextualSubtable
{
buffer->unsafe_to_break (mark, hb_min (buffer->idx + 1, buffer->len));
buffer->info[mark].codepoint = *replacement;
if (has_glyph_classes)
_hb_glyph_info_set_glyph_props (&buffer->info[mark],
gdef.get_glyph_props (*replacement));
ret = true;
}
@ -287,6 +293,9 @@ struct ContextualSubtable
if (replacement)
{
buffer->info[idx].codepoint = *replacement;
if (has_glyph_classes)
_hb_glyph_info_set_glyph_props (&buffer->info[idx],
gdef.get_glyph_props (*replacement));
ret = true;
}
@ -301,7 +310,9 @@ struct ContextualSubtable
bool ret;
private:
hb_aat_apply_context_t *c;
const OT::GDEF &gdef;
bool mark_set;
bool has_glyph_classes;
unsigned int mark;
const ContextualSubtable *table;
const UnsizedListOfOffset16To<Lookup<HBGlyphID>, HBUINT, false> &subs;
@ -599,6 +610,9 @@ struct NoncontextualSubtable
{
TRACE_APPLY (this);
const OT::GDEF &gdef (*c->gdef_table);
bool has_glyph_classes = gdef.has_glyph_classes ();
bool ret = false;
unsigned int num_glyphs = c->face->get_num_glyphs ();
@ -610,6 +624,9 @@ struct NoncontextualSubtable
if (replacement)
{
info[i].codepoint = *replacement;
if (has_glyph_classes)
_hb_glyph_info_set_glyph_props (&info[i],
gdef.get_glyph_props (*replacement));
ret = true;
}
}

Просмотреть файл

@ -55,6 +55,7 @@ AAT::hb_aat_apply_context_t::hb_aat_apply_context_t (const hb_ot_shape_plan_t *p
buffer (buffer_),
sanitizer (),
ankr_table (&Null (AAT::ankr)),
gdef_table (face->table.GDEF->table),
lookup_index (0)
{
sanitizer.init (blob);
@ -79,7 +80,7 @@ AAT::hb_aat_apply_context_t::set_ankr_table (const AAT::ankr *ankr_table_)
* @short_description: Apple Advanced Typography Layout
* @include: hb-aat.h
*
* Functions for querying AAT Layout features in the font face.
* Functions for querying AAT Layout features in the font face.
*
* HarfBuzz supports all of the AAT tables used to implement shaping. Other
* AAT tables and their associated features are not supported.
@ -172,13 +173,13 @@ static const hb_aat_feature_mapping_t feature_mappings[] =
{HB_TAG ('z','e','r','o'), HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS, HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_ON, HB_AAT_LAYOUT_FEATURE_SELECTOR_SLASHED_ZERO_OFF},
};
/**
/**
* hb_aat_layout_find_feature_mapping:
* @tag: The requested #hb_tag_t feature tag
*
* Fetches the AAT feature-and-selector combination that corresponds
* to a given OpenType feature tag.
*
*
* Return value: the AAT features and selectors corresponding to the
* OpenType feature tag queried
*

Просмотреть файл

@ -193,6 +193,12 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
script_fallback_mark_positioning;
#ifndef HB_NO_AAT_SHAPE
/* If we're using morx shaping, we cancel mark position adjustment because
Apple Color Emoji assumes this will NOT be done when forming emoji sequences;
https://github.com/harfbuzz/harfbuzz/issues/2967. */
if (plan.apply_morx)
plan.adjust_mark_positioning_when_zeroing = false;
/* Currently we always apply trak. */
plan.apply_trak = plan.requested_tracking && hb_aat_layout_has_tracking (face);
#endif
@ -1164,7 +1170,7 @@ _hb_ot_shape (hb_shape_plan_t *shape_plan,
* @lookup_indexes: (out): The #hb_set_t set of lookups returned
*
* Computes the complete set of GSUB or GPOS lookups that are applicable
* under a given @shape_plan.
* under a given @shape_plan.
*
* Since: 0.9.7
**/

Просмотреть файл

@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<body style="text-rendering: optimizeLegibility; background-color: white">
<body style="text-rendering: optimizeLegibility; background-color: white;
letter-spacing: 2px;">
<p>&#x0305;<span style="color: white">-hidden</span></p>
</body>
</html>

Просмотреть файл

@ -1,6 +1,9 @@
<!DOCTYPE html>
<html>
<body style="text-rendering: optimizeLegibility; background-color: white">
<!-- Use letter-spacing in the style to keep the antialiased edges of the glyph
from being erased by the following white span in the reference -->
<body style="text-rendering: optimizeLegibility; background-color: white;
letter-spacing: 2px;">
<p>&#x0305;</p>
</body>
</html>