[aat] Update glyph properties from GDEF if available when doing a replacement.

This commit is contained in:
Jonathan Kew 2021-05-05 11:11:43 +01:00 committed by Behdad Esfahbod
parent 5e0ec33b3d
commit 4f1e8d2bf7
3 changed files with 25 additions and 3 deletions

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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
*