Skip to content

Commit

Permalink
rework handling of requiredFeature to solve problem with rlig in aria…
Browse files Browse the repository at this point in the history
…l.ttf from winxp [mozilla bug 986802]
  • Loading branch information
jfkthame committed Apr 27, 2014
1 parent a2549b8 commit 35e28c7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 24 deletions.
26 changes: 15 additions & 11 deletions src/hb-ot-layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,18 @@ hb_ot_layout_script_find_language (hb_face_t *face,
}

hb_bool_t
hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
hb_tag_t table_tag,
unsigned int script_index,
unsigned int language_index,
unsigned int *feature_index)
hb_ot_layout_language_get_required_feature (hb_face_t *face,
hb_tag_t table_tag,
unsigned int script_index,
unsigned int language_index,
hb_tag_t *feature_tag,
unsigned int *feature_index)
{
const OT::LangSys &l = get_gsubgpos_table (face, table_tag).get_script (script_index).get_lang_sys (language_index);
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);

if (feature_index) *feature_index = l.get_required_feature_index ();
if (feature_tag) *feature_tag = g.get_feature_tag (l.get_required_feature_index ());

return l.has_required_feature ();
}
Expand Down Expand Up @@ -468,11 +471,12 @@ _hb_ot_layout_collect_lookups_features (hb_face_t *face,
if (!features)
{
unsigned int required_feature_index;
if (hb_ot_layout_language_get_required_feature_index (face,
table_tag,
script_index,
language_index,
&required_feature_index))
if (hb_ot_layout_language_get_required_feature (face,
table_tag,
script_index,
language_index,
NULL,
&required_feature_index))
_hb_ot_layout_collect_lookups_lookups (face,
table_tag,
required_feature_index,
Expand Down
11 changes: 6 additions & 5 deletions src/hb-ot-layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,12 @@ hb_ot_layout_script_find_language (hb_face_t *face,
unsigned int *language_index);

hb_bool_t
hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
hb_tag_t table_tag,
unsigned int script_index,
unsigned int language_index,
unsigned int *feature_index);
hb_ot_layout_language_get_required_feature (hb_face_t *face,
hb_tag_t table_tag,
unsigned int script_index,
unsigned int language_index,
hb_tag_t *feature_tag,
unsigned int *feature_index);

unsigned int
hb_ot_layout_language_get_feature_indexes (hb_face_t *face,
Expand Down
36 changes: 28 additions & 8 deletions src/hb-ot-map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,19 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m)
{
m.global_mask = 1;

hb_tag_t required_feature_tag[2];
unsigned int required_feature_index[2];

for (unsigned int table_index = 0; table_index < 2; table_index++) {
m.chosen_script[table_index] = chosen_script[table_index];
m.found_script[table_index] = found_script[table_index];

hb_ot_layout_language_get_required_feature (face,
table_tags[table_index],
script_index[table_index],
language_index[table_index],
&required_feature_tag[table_index],
&required_feature_index[table_index]);
}

if (!feature_infos.len)
Expand Down Expand Up @@ -183,13 +193,21 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m)

hb_bool_t found = false;
unsigned int feature_index[2];
for (unsigned int table_index = 0; table_index < 2; table_index++)
for (unsigned int table_index = 0; table_index < 2; table_index++) {
if (required_feature_index[table_index] != HB_OT_LAYOUT_NO_FEATURE_INDEX &&
required_feature_tag[table_index] == info->tag) {
feature_index[table_index] = required_feature_index[table_index];
required_feature_index[table_index] = HB_OT_LAYOUT_NO_FEATURE_INDEX;
found = true;
continue;
}
found |= hb_ot_layout_language_find_feature (face,
table_tags[table_index],
script_index[table_index],
language_index[table_index],
info->tag,
&feature_index[table_index]);
}
if (!found && !(info->flags & F_HAS_FALLBACK))
continue;

Expand Down Expand Up @@ -229,13 +247,15 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m)

/* Collect lookup indices for features */

unsigned int required_feature_index;
if (hb_ot_layout_language_get_required_feature_index (face,
table_tag,
script_index[table_index],
language_index[table_index],
&required_feature_index))
m.add_lookups (face, table_index, required_feature_index, 1, true);
/* XXX
* Normally, any required feature will have been handled by the allocate-bits
* loop above. However, if the feature tag was not known among the features
* being applied by the shaper, then it won't have been processed yet - and
* we have no basis for knowing which stage to assign it to. We arbitrarily
* add its lookups here, before everything else, and hope that'll be OK.
*/
if (required_feature_index[table_index] != HB_OT_LAYOUT_NO_FEATURE_INDEX)
m.add_lookups (face, table_index, required_feature_index[table_index], 1, true);

unsigned int stage_index = 0;
unsigned int last_num_lookups = 0;
Expand Down

0 comments on commit 35e28c7

Please sign in to comment.