Adjust mark offsets when zeroing from fallback mark positioning code

Adjust tests.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1532
This commit is contained in:
Behdad Esfahbod 2019-01-24 12:08:23 +01:00
parent 36fb2b4da9
commit 3ecda71041
6 changed files with 30 additions and 15 deletions

View File

@ -180,12 +180,18 @@ _hb_ot_shape_fallback_mark_position_recategorize_marks (const hb_ot_shape_plan_t
static void
zero_mark_advances (hb_buffer_t *buffer,
unsigned int start,
unsigned int end)
unsigned int end,
bool adjust_offsets_when_zeroing)
{
hb_glyph_info_t *info = buffer->info;
for (unsigned int i = start; i < end; i++)
if (_hb_glyph_info_get_general_category (&info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
{
if (adjust_offsets_when_zeroing)
{
buffer->pos[i].x_offset -= buffer->pos[i].x_advance;
buffer->pos[i].y_offset -= buffer->pos[i].y_advance;
}
buffer->pos[i].x_advance = 0;
buffer->pos[i].y_advance = 0;
}
@ -303,7 +309,8 @@ position_around_base (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer,
unsigned int base,
unsigned int end)
unsigned int end,
bool adjust_offsets_when_zeroing)
{
hb_direction_t horiz_dir = HB_DIRECTION_INVALID;
@ -314,11 +321,15 @@ position_around_base (const hb_ot_shape_plan_t *plan,
&base_extents))
{
/* If extents don't work, zero marks and go home. */
zero_mark_advances (buffer, base + 1, end);
zero_mark_advances (buffer, base + 1, end, adjust_offsets_when_zeroing);
return;
}
base_extents.x_bearing += buffer->pos[base].x_offset;
base_extents.y_bearing += buffer->pos[base].y_offset;
/* Use horizontal advance for horizontal positioning.
* Generally a better idea. Also works for zero-ink glyphs. See:
* https://github.com/harfbuzz/harfbuzz/issues/1532 */
base_extents.x_bearing = 0;
base_extents.width = font->get_glyph_h_advance (buffer->info[base].codepoint);
unsigned int lig_id = _hb_glyph_info_get_lig_id (&buffer->info[base]);
/* Use integer for num_lig_components such that it doesn't convert to unsigned
@ -394,7 +405,8 @@ position_cluster (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer,
unsigned int start,
unsigned int end)
unsigned int end,
bool adjust_offsets_when_zeroing)
{
if (end - start < 2)
return;
@ -410,7 +422,7 @@ position_cluster (const hb_ot_shape_plan_t *plan,
if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[j])))
break;
position_around_base (plan, font, buffer, i, j);
position_around_base (plan, font, buffer, i, j, adjust_offsets_when_zeroing);
i = j - 1;
}
@ -419,7 +431,8 @@ position_cluster (const hb_ot_shape_plan_t *plan,
void
_hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
hb_buffer_t *buffer,
bool adjust_offsets_when_zeroing)
{
_hb_buffer_assert_gsubgpos_vars (buffer);
@ -428,10 +441,10 @@ _hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan,
hb_glyph_info_t *info = buffer->info;
for (unsigned int i = 1; i < count; i++)
if (likely (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[i])))) {
position_cluster (plan, font, buffer, start, i);
position_cluster (plan, font, buffer, start, i, adjust_offsets_when_zeroing);
start = i;
}
position_cluster (plan, font, buffer, start, count);
position_cluster (plan, font, buffer, start, count, adjust_offsets_when_zeroing);
}

View File

@ -34,7 +34,8 @@
HB_INTERNAL void _hb_ot_shape_fallback_mark_position (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer);
hb_buffer_t *buffer,
bool adjust_offsets_when_zeroing);
HB_INTERNAL void _hb_ot_shape_fallback_mark_position_recategorize_marks (const hb_ot_shape_plan_t *plan,
hb_font_t *font,

View File

@ -891,7 +891,8 @@ hb_ot_position_complex (const hb_ot_shape_context_t *c)
&pos[i].y_offset);
if (c->plan->fallback_mark_positioning)
_hb_ot_shape_fallback_mark_position (c->plan, c->font, c->buffer);
_hb_ot_shape_fallback_mark_position (c->plan, c->font, c->buffer,
adjust_offsets_when_zeroing);
}
static inline void

View File

@ -1 +1 @@
../fonts/df768b9c257e0c9c35786c47cae15c46571d56be.ttf::U+0633,U+064F,U+0644,U+064E,U+0651,U+0627,U+0651,U+0650,U+0645,U+062A,U+06CC:[uni06CC.fina=10+1655|uni062A.medi=9+868|uni0645.init=8+1098|uni0650=2@221,0+0|uni0651=2@260,736+0|uni064E=2@935,1259+0|uni0651=2@974,736+0|uni06440627.fina=2+1470|uni064F=0@558,-10+0|uni0633.init=0+1585]
../fonts/df768b9c257e0c9c35786c47cae15c46571d56be.ttf::U+0633,U+064F,U+0644,U+064E,U+0651,U+0627,U+0651,U+0650,U+0645,U+062A,U+06CC:[uni06CC.fina=10+1655|uni062A.medi=9+868|uni0645.init=8+1098|uni0650=2@148,0+0|uni0651=2@187,736+0|uni064E=2@883,1259+0|uni0651=2@922,736+0|uni06440627.fina=2+1470|uni064F=0@629,-10+0|uni0633.init=0+1585]

View File

@ -1,2 +1,2 @@
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf:--cluster-level=2:U+0078,U+030A,U+0058,U+030A:[gid2=0+1083|gid3=1@-1131,-8+0|gid1=2+1200|gid3=3@-1190,349+0]
../fonts/4fac3929fc3332834e93673780ec0fe94342d193.ttf:--cluster-level=2:U+0078,U+030A,U+0058,U+030A:[gid2=0+1083|gid3=1@-1132,-8+0|gid1=2+1200|gid3=3@-1190,349+0]
../fonts/43ef465752be9af900745f72fe29cb853a1401a5.ttf:--cluster-level=1:U+05D4,U+05B7,U+05E9,U+05BC,U+05C1,U+05B8,U+05DE,U+05B4,U+05DD:[uni05DD=8+1359|uni05B4=7@111,0+0|uni05DE=6+1391|uni05B8=5+0|uni05BC=3+0|uni05C1=3+0|uni05E9=2+1451|uni05B7=1@28,0+0|uni05D4=0+1338]

View File

@ -1,2 +1,2 @@
../fonts/8228d035fcd65d62ec9728fb34f42c63be93a5d3.ttf::U+0078,U+0301,U+0058,U+0301:[x=0+1030|acutecomb=0@-21,-27+0|X=2+1295|acutecomb=2@-147,320+0]
../fonts/856ff9562451293cbeff6f396d4e3877c4f0a436.ttf::U+0061,U+035C,U+0062:[uni0061=0+512|uni035C=0@-64,-128+0|uni0062=2+512]
../fonts/8228d035fcd65d62ec9728fb34f42c63be93a5d3.ttf::U+0078,U+0301,U+0058,U+0301:[x=0+1030|acutecomb=0@-19,-27+0|X=2+1295|acutecomb=2@-151,320+0]
../fonts/856ff9562451293cbeff6f396d4e3877c4f0a436.ttf::U+0061,U+035C,U+0062:[uni0061=0+512|uni035C=0@0,-128+0|uni0062=2+512]