Reordering fails when GDEF table is absent #2140
Preserve glyph class if there's no GDEF and no guess. Fixes https://github.com/harfbuzz/harfbuzz/issues/2140
This commit is contained in:
parent
05be05eb65
commit
f4cd99f28e
|
@ -645,53 +645,56 @@ struct hb_ot_apply_context_t :
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _set_glyph_props (hb_codepoint_t glyph_index,
|
void _set_glyph_class (hb_codepoint_t glyph_index,
|
||||||
unsigned int class_guess = 0,
|
unsigned int class_guess = 0,
|
||||||
bool ligature = false,
|
bool ligature = false,
|
||||||
bool component = false) const
|
bool component = false) const
|
||||||
{
|
{
|
||||||
unsigned int add_in = _hb_glyph_info_get_glyph_props (&buffer->cur()) &
|
unsigned int props = _hb_glyph_info_get_glyph_props (&buffer->cur());
|
||||||
HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE;
|
|
||||||
add_in |= HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED;
|
props |= HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED;
|
||||||
if (ligature)
|
if (ligature)
|
||||||
{
|
{
|
||||||
add_in |= HB_OT_LAYOUT_GLYPH_PROPS_LIGATED;
|
props |= HB_OT_LAYOUT_GLYPH_PROPS_LIGATED;
|
||||||
/* In the only place that the MULTIPLIED bit is used, Uniscribe
|
/* In the only place that the MULTIPLIED bit is used, Uniscribe
|
||||||
* seems to only care about the "last" transformation between
|
* seems to only care about the "last" transformation between
|
||||||
* Ligature and Multiple substitutions. Ie. if you ligate, expand,
|
* Ligature and Multiple substitutions. Ie. if you ligate, expand,
|
||||||
* and ligate again, it forgives the multiplication and acts as
|
* and ligate again, it forgives the multiplication and acts as
|
||||||
* if only ligation happened. As such, clear MULTIPLIED bit.
|
* if only ligation happened. As such, clear MULTIPLIED bit.
|
||||||
*/
|
*/
|
||||||
add_in &= ~HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED;
|
props &= ~HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED;
|
||||||
}
|
}
|
||||||
if (component)
|
if (component)
|
||||||
add_in |= HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED;
|
props |= HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED;
|
||||||
|
|
||||||
if (likely (has_glyph_classes))
|
if (likely (has_glyph_classes))
|
||||||
_hb_glyph_info_set_glyph_props (&buffer->cur(), add_in | gdef.get_glyph_props (glyph_index));
|
props = (props & ~HB_OT_LAYOUT_GLYPH_PROPS_CLASS_MASK) | gdef.get_glyph_props (glyph_index);
|
||||||
else if (class_guess)
|
else if (class_guess)
|
||||||
_hb_glyph_info_set_glyph_props (&buffer->cur(), add_in | class_guess);
|
props = (props & ~HB_OT_LAYOUT_GLYPH_PROPS_CLASS_MASK) | class_guess;
|
||||||
|
|
||||||
|
_hb_glyph_info_set_glyph_props (&buffer->cur(), props);
|
||||||
}
|
}
|
||||||
|
|
||||||
void replace_glyph (hb_codepoint_t glyph_index) const
|
void replace_glyph (hb_codepoint_t glyph_index) const
|
||||||
{
|
{
|
||||||
_set_glyph_props (glyph_index);
|
_set_glyph_class (glyph_index);
|
||||||
buffer->replace_glyph (glyph_index);
|
buffer->replace_glyph (glyph_index);
|
||||||
}
|
}
|
||||||
void replace_glyph_inplace (hb_codepoint_t glyph_index) const
|
void replace_glyph_inplace (hb_codepoint_t glyph_index) const
|
||||||
{
|
{
|
||||||
_set_glyph_props (glyph_index);
|
_set_glyph_class (glyph_index);
|
||||||
buffer->cur().codepoint = glyph_index;
|
buffer->cur().codepoint = glyph_index;
|
||||||
}
|
}
|
||||||
void replace_glyph_with_ligature (hb_codepoint_t glyph_index,
|
void replace_glyph_with_ligature (hb_codepoint_t glyph_index,
|
||||||
unsigned int class_guess) const
|
unsigned int class_guess) const
|
||||||
{
|
{
|
||||||
_set_glyph_props (glyph_index, class_guess, true);
|
_set_glyph_class (glyph_index, class_guess, true);
|
||||||
buffer->replace_glyph (glyph_index);
|
buffer->replace_glyph (glyph_index);
|
||||||
}
|
}
|
||||||
void output_glyph_for_component (hb_codepoint_t glyph_index,
|
void output_glyph_for_component (hb_codepoint_t glyph_index,
|
||||||
unsigned int class_guess) const
|
unsigned int class_guess) const
|
||||||
{
|
{
|
||||||
_set_glyph_props (glyph_index, class_guess, false, true);
|
_set_glyph_class (glyph_index, class_guess, false, true);
|
||||||
buffer->output_glyph (glyph_index);
|
buffer->output_glyph (glyph_index);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,14 +80,14 @@ enum hb_ot_layout_glyph_props_flags_t
|
||||||
HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE = 0x04u,
|
HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE = 0x04u,
|
||||||
HB_OT_LAYOUT_GLYPH_PROPS_MARK = 0x08u,
|
HB_OT_LAYOUT_GLYPH_PROPS_MARK = 0x08u,
|
||||||
|
|
||||||
|
HB_OT_LAYOUT_GLYPH_PROPS_CLASS_MASK = HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH |
|
||||||
|
HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE |
|
||||||
|
HB_OT_LAYOUT_GLYPH_PROPS_MARK,
|
||||||
|
|
||||||
/* The following are used internally; not derived from GDEF. */
|
/* The following are used internally; not derived from GDEF. */
|
||||||
HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED = 0x10u,
|
HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED = 0x10u,
|
||||||
HB_OT_LAYOUT_GLYPH_PROPS_LIGATED = 0x20u,
|
HB_OT_LAYOUT_GLYPH_PROPS_LIGATED = 0x20u,
|
||||||
HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED = 0x40u,
|
HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED = 0x40u,
|
||||||
|
|
||||||
HB_OT_LAYOUT_GLYPH_PROPS_PRESERVE = HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED |
|
|
||||||
HB_OT_LAYOUT_GLYPH_PROPS_LIGATED |
|
|
||||||
HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED
|
|
||||||
};
|
};
|
||||||
HB_MARK_AS_FLAG_T (hb_ot_layout_glyph_props_flags_t);
|
HB_MARK_AS_FLAG_T (hb_ot_layout_glyph_props_flags_t);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue