summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/harfbuzz-ng/src/hb-ot-shape-fallback.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-ot-shape-fallback.cc')
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-ot-shape-fallback.cc73
1 files changed, 49 insertions, 24 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-ot-shape-fallback.cc b/src/3rdparty/harfbuzz-ng/src/hb-ot-shape-fallback.cc
index 284d030d5f..449b64e5ca 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-ot-shape-fallback.cc
+++ b/src/3rdparty/harfbuzz-ng/src/hb-ot-shape-fallback.cc
@@ -260,7 +260,13 @@ position_mark (const hb_ot_shape_plan_t *plan,
case HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW_LEFT:
case HB_UNICODE_COMBINING_CLASS_ATTACHED_BELOW:
- pos.y_offset += base_extents.y_bearing + base_extents.height - mark_extents.y_bearing;
+ pos.y_offset = base_extents.y_bearing + base_extents.height - mark_extents.y_bearing;
+ /* Never shift up "below" marks. */
+ if ((y_gap > 0) == (pos.y_offset > 0))
+ {
+ base_extents.height -= pos.y_offset;
+ pos.y_offset = 0;
+ }
base_extents.height += mark_extents.height;
break;
@@ -274,7 +280,15 @@ position_mark (const hb_ot_shape_plan_t *plan,
case HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE:
case HB_UNICODE_COMBINING_CLASS_ATTACHED_ABOVE_RIGHT:
- pos.y_offset += base_extents.y_bearing - (mark_extents.y_bearing + mark_extents.height);
+ pos.y_offset = base_extents.y_bearing - (mark_extents.y_bearing + mark_extents.height);
+ /* Don't shift down "above" marks too much. */
+ if ((y_gap > 0) != (pos.y_offset > 0))
+ {
+ unsigned int correction = -pos.y_offset / 2;
+ base_extents.y_bearing += correction;
+ base_extents.height -= correction;
+ pos.y_offset += correction;
+ }
base_extents.y_bearing -= mark_extents.height;
base_extents.height += mark_extents.height;
break;
@@ -300,8 +314,8 @@ position_around_base (const hb_ot_shape_plan_t *plan,
base_extents.x_bearing += buffer->pos[base].x_offset;
base_extents.y_bearing += buffer->pos[base].y_offset;
- unsigned int lig_id = get_lig_id (buffer->info[base]);
- unsigned int num_lig_components = get_lig_num_comps (buffer->info[base]);
+ unsigned int lig_id = _hb_glyph_info_get_lig_id (&buffer->info[base]);
+ unsigned int num_lig_components = _hb_glyph_info_get_lig_num_comps (&buffer->info[base]);
hb_position_t x_offset = 0, y_offset = 0;
if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) {
@@ -317,8 +331,8 @@ position_around_base (const hb_ot_shape_plan_t *plan,
if (_hb_glyph_info_get_modified_combining_class (&buffer->info[i]))
{
if (num_lig_components > 1) {
- unsigned int this_lig_id = get_lig_id (buffer->info[i]);
- unsigned int this_lig_component = get_lig_comp (buffer->info[i]) - 1;
+ unsigned int this_lig_id = _hb_glyph_info_get_lig_id (&buffer->info[i]);
+ unsigned int this_lig_component = _hb_glyph_info_get_lig_comp (&buffer->info[i]) - 1;
/* Conditions for attaching to the last component. */
if (!lig_id || lig_id != this_lig_id || this_lig_component >= num_lig_components)
this_lig_component = num_lig_components - 1;
@@ -416,41 +430,52 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
- unsigned int count = buffer->len;
hb_mask_t kern_mask = plan->map.get_1_mask (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction) ?
HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n'));
+ if (!kern_mask) return;
+
+ unsigned int count = buffer->len;
OT::hb_apply_context_t c (1, font, buffer);
c.set_lookup_mask (kern_mask);
c.set_lookup_props (OT::LookupFlag::IgnoreMarks);
- for (buffer->idx = 0; buffer->idx < count;)
+ hb_glyph_info_t *info = buffer->info;
+ hb_glyph_position_t *pos = buffer->pos;
+
+ for (unsigned int idx = 0; idx < count;)
{
- OT::hb_apply_context_t::skipping_forward_iterator_t skippy_iter (&c, buffer->idx, 1);
+ OT::hb_apply_context_t::skipping_forward_iterator_t skippy_iter (&c, idx, 1);
if (!skippy_iter.next ())
{
- buffer->idx++;
+ idx++;
continue;
}
- hb_position_t x_kern, y_kern, kern1, kern2;
- font->get_glyph_kerning_for_direction (buffer->info[buffer->idx].codepoint,
- buffer->info[skippy_iter.idx].codepoint,
+ hb_position_t x_kern, y_kern;
+ font->get_glyph_kerning_for_direction (info[idx].codepoint,
+ info[skippy_iter.idx].codepoint,
buffer->props.direction,
&x_kern, &y_kern);
- kern1 = x_kern >> 1;
- kern2 = x_kern - kern1;
- buffer->pos[buffer->idx].x_advance += kern1;
- buffer->pos[skippy_iter.idx].x_advance += kern2;
- buffer->pos[skippy_iter.idx].x_offset += kern2;
+ if (x_kern)
+ {
+ hb_position_t kern1 = x_kern >> 1;
+ hb_position_t kern2 = x_kern - kern1;
+ pos[idx].x_advance += kern1;
+ pos[skippy_iter.idx].x_advance += kern2;
+ pos[skippy_iter.idx].x_offset += kern2;
+ }
- kern1 = y_kern >> 1;
- kern2 = y_kern - kern1;
- buffer->pos[buffer->idx].y_advance += kern1;
- buffer->pos[skippy_iter.idx].y_advance += kern2;
- buffer->pos[skippy_iter.idx].y_offset += kern2;
+ if (y_kern)
+ {
+ hb_position_t kern1 = y_kern >> 1;
+ hb_position_t kern2 = y_kern - kern1;
+ pos[idx].y_advance += kern1;
+ pos[skippy_iter.idx].y_advance += kern2;
+ pos[skippy_iter.idx].y_offset += kern2;
+ }
- buffer->idx = skippy_iter.idx;
+ idx = skippy_iter.idx;
}
}