Skip to content

Commit 35e28c7

Browse files
committed
rework handling of requiredFeature to solve problem with rlig in arial.ttf from winxp [mozilla bug 986802]
1 parent a2549b8 commit 35e28c7

File tree

3 files changed

+49
-24
lines changed

3 files changed

+49
-24
lines changed

src/hb-ot-layout.cc

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,18 @@ hb_ot_layout_script_find_language (hb_face_t *face,
321321
}
322322

323323
hb_bool_t
324-
hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
325-
hb_tag_t table_tag,
326-
unsigned int script_index,
327-
unsigned int language_index,
328-
unsigned int *feature_index)
324+
hb_ot_layout_language_get_required_feature (hb_face_t *face,
325+
hb_tag_t table_tag,
326+
unsigned int script_index,
327+
unsigned int language_index,
328+
hb_tag_t *feature_tag,
329+
unsigned int *feature_index)
329330
{
330-
const OT::LangSys &l = get_gsubgpos_table (face, table_tag).get_script (script_index).get_lang_sys (language_index);
331+
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
332+
const OT::LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
331333

332334
if (feature_index) *feature_index = l.get_required_feature_index ();
335+
if (feature_tag) *feature_tag = g.get_feature_tag (l.get_required_feature_index ());
333336

334337
return l.has_required_feature ();
335338
}
@@ -468,11 +471,12 @@ _hb_ot_layout_collect_lookups_features (hb_face_t *face,
468471
if (!features)
469472
{
470473
unsigned int required_feature_index;
471-
if (hb_ot_layout_language_get_required_feature_index (face,
472-
table_tag,
473-
script_index,
474-
language_index,
475-
&required_feature_index))
474+
if (hb_ot_layout_language_get_required_feature (face,
475+
table_tag,
476+
script_index,
477+
language_index,
478+
NULL,
479+
&required_feature_index))
476480
_hb_ot_layout_collect_lookups_lookups (face,
477481
table_tag,
478482
required_feature_index,

src/hb-ot-layout.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,12 @@ hb_ot_layout_script_find_language (hb_face_t *face,
140140
unsigned int *language_index);
141141

142142
hb_bool_t
143-
hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
144-
hb_tag_t table_tag,
145-
unsigned int script_index,
146-
unsigned int language_index,
147-
unsigned int *feature_index);
143+
hb_ot_layout_language_get_required_feature (hb_face_t *face,
144+
hb_tag_t table_tag,
145+
unsigned int script_index,
146+
unsigned int language_index,
147+
hb_tag_t *feature_tag,
148+
unsigned int *feature_index);
148149

149150
unsigned int
150151
hb_ot_layout_language_get_feature_indexes (hb_face_t *face,

src/hb-ot-map.cc

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,19 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m)
131131
{
132132
m.global_mask = 1;
133133

134+
hb_tag_t required_feature_tag[2];
135+
unsigned int required_feature_index[2];
136+
134137
for (unsigned int table_index = 0; table_index < 2; table_index++) {
135138
m.chosen_script[table_index] = chosen_script[table_index];
136139
m.found_script[table_index] = found_script[table_index];
140+
141+
hb_ot_layout_language_get_required_feature (face,
142+
table_tags[table_index],
143+
script_index[table_index],
144+
language_index[table_index],
145+
&required_feature_tag[table_index],
146+
&required_feature_index[table_index]);
137147
}
138148

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

184194
hb_bool_t found = false;
185195
unsigned int feature_index[2];
186-
for (unsigned int table_index = 0; table_index < 2; table_index++)
196+
for (unsigned int table_index = 0; table_index < 2; table_index++) {
197+
if (required_feature_index[table_index] != HB_OT_LAYOUT_NO_FEATURE_INDEX &&
198+
required_feature_tag[table_index] == info->tag) {
199+
feature_index[table_index] = required_feature_index[table_index];
200+
required_feature_index[table_index] = HB_OT_LAYOUT_NO_FEATURE_INDEX;
201+
found = true;
202+
continue;
203+
}
187204
found |= hb_ot_layout_language_find_feature (face,
188205
table_tags[table_index],
189206
script_index[table_index],
190207
language_index[table_index],
191208
info->tag,
192209
&feature_index[table_index]);
210+
}
193211
if (!found && !(info->flags & F_HAS_FALLBACK))
194212
continue;
195213

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

230248
/* Collect lookup indices for features */
231249

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

240260
unsigned int stage_index = 0;
241261
unsigned int last_num_lookups = 0;

0 commit comments

Comments
 (0)