summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/harfbuzz-ng/src/hb-ot-shape.cc
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-08-20 10:31:40 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-08-23 07:37:04 +0200
commitd8f815db7f5eb2bdfb911dbf6d28da17c0a47025 (patch)
tree61c296bd8e694ef8e6d238d93fb9835ff5bea939 /src/3rdparty/harfbuzz-ng/src/hb-ot-shape.cc
parentd07742f333df89dc399fc5d9cabf2bdef0b346c5 (diff)
Update Harfbuzz to version 2.9.0
[ChangeLog][Text] Updated bundled Harfbuzz to version 2.9.0. Pick-to: 6.2 Change-Id: Ib8fed753b99a127d5a4cc793c5c1d55a0090f902 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-ot-shape.cc')
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-ot-shape.cc71
1 files changed, 62 insertions, 9 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-ot-shape.cc b/src/3rdparty/harfbuzz-ng/src/hb-ot-shape.cc
index 86ab0b4268..90d0d99a04 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-ot-shape.cc
+++ b/src/3rdparty/harfbuzz-ng/src/hb-ot-shape.cc
@@ -149,13 +149,15 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
* Decide who does positioning. GPOS, kerx, kern, or fallback.
*/
- if (0)
+ bool has_gsub = hb_ot_layout_has_substitution (face);
+ bool has_gpos = !disable_gpos && hb_ot_layout_has_positioning (face);
+ if (false)
;
#ifndef HB_NO_AAT_SHAPE
- else if (hb_aat_layout_has_positioning (face))
+ else if (hb_aat_layout_has_positioning (face) && !(has_gsub && has_gpos))
plan.apply_kerx = true;
#endif
- else if (!apply_morx && !disable_gpos && hb_ot_layout_has_positioning (face))
+ else if (!apply_morx && has_gpos)
plan.apply_gpos = true;
if (!plan.apply_kerx && (!has_gpos_kern || !plan.apply_gpos))
@@ -172,6 +174,8 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
#endif
}
+ plan.apply_fallback_kern = !(plan.apply_gpos || plan.apply_kerx || plan.apply_kern);
+
plan.zero_marks = script_zero_marks &&
!plan.apply_kerx &&
(!plan.apply_kern
@@ -193,6 +197,12 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
script_fallback_mark_positioning;
#ifndef HB_NO_AAT_SHAPE
+ /* If we're using morx shaping, we cancel mark position adjustment because
+ Apple Color Emoji assumes this will NOT be done when forming emoji sequences;
+ https://github.com/harfbuzz/harfbuzz/issues/2967. */
+ if (plan.apply_morx)
+ plan.adjust_mark_positioning_when_zeroing = false;
+
/* Currently we always apply trak. */
plan.apply_trak = plan.requested_tracking && hb_aat_layout_has_tracking (face);
#endif
@@ -266,11 +276,12 @@ hb_ot_shape_plan_t::position (hb_font_t *font,
else if (this->apply_kerx)
hb_aat_layout_position (this, font, buffer);
#endif
+
#ifndef HB_NO_OT_KERN
- else if (this->apply_kern)
+ if (this->apply_kern)
hb_ot_layout_kern (this, font, buffer);
#endif
- else
+ else if (this->apply_fallback_kern)
_hb_ot_shape_fallback_kern (this, font, buffer);
#ifndef HB_NO_AAT_SHAPE
@@ -363,6 +374,10 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
map->add_feature (horizontal_features[i]);
else
{
+ /* We only apply `vert` feature. See:
+ * https://github.com/harfbuzz/harfbuzz/commit/d71c0df2d17f4590d5611239577a6cb532c26528
+ * https://lists.freedesktop.org/archives/harfbuzz/2013-August/003490.html */
+
/* We really want to find a 'vert' feature if there's any in the font, no
* matter which script/langsys it is listed (or not) under.
* See various bugs referenced from:
@@ -478,6 +493,14 @@ hb_set_unicode_props (hb_buffer_t *buffer)
if (unlikely (_hb_glyph_info_get_general_category (&info[i]) == HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL &&
hb_in_range<hb_codepoint_t> (info[i].codepoint, 0x1F3FBu, 0x1F3FFu)))
{
+ _hb_glyph_info_set_continuation (&info[i]);
+ }
+ /* Regional_Indicators are hairy as hell...
+ * https://github.com/harfbuzz/harfbuzz/issues/2265 */
+ else if (unlikely (i && hb_in_range<hb_codepoint_t> (info[i].codepoint, 0x1F1E6u, 0x1F1FFu)))
+ {
+ if (hb_in_range<hb_codepoint_t> (info[i - 1].codepoint, 0x1F1E6u, 0x1F1FFu) &&
+ !_hb_glyph_info_is_continuation (&info[i - 1]))
_hb_glyph_info_set_continuation (&info[i]);
}
#ifndef HB_NO_EMOJI_SEQUENCES
@@ -535,6 +558,7 @@ hb_insert_dotted_circle (hb_buffer_t *buffer, hb_font_t *font)
info.cluster = buffer->cur().cluster;
info.mask = buffer->cur().mask;
(void) buffer->output_info (info);
+
buffer->swap_buffers ();
}
@@ -558,6 +582,36 @@ hb_ensure_native_direction (hb_buffer_t *buffer)
hb_direction_t direction = buffer->props.direction;
hb_direction_t horiz_dir = hb_script_get_horizontal_direction (buffer->props.script);
+ /* Numeric runs in natively-RTL scripts are actually native-LTR, so we reset
+ * the horiz_dir if the run contains at least one decimal-number char, and no
+ * letter chars (ideally we should be checking for chars with strong
+ * directionality but hb-unicode currently lacks bidi categories).
+ *
+ * This allows digit sequences in Arabic etc to be shaped in "native"
+ * direction, so that features like ligatures will work as intended.
+ *
+ * https://github.com/harfbuzz/harfbuzz/issues/501
+ */
+ if (unlikely (horiz_dir == HB_DIRECTION_RTL && direction == HB_DIRECTION_LTR))
+ {
+ bool found_number = false, found_letter = false;
+ const auto* info = buffer->info;
+ const auto count = buffer->len;
+ for (unsigned i = 0; i < count; i++)
+ {
+ auto gc = _hb_glyph_info_get_general_category (&info[i]);
+ if (gc == HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER)
+ found_number = true;
+ else if (HB_UNICODE_GENERAL_CATEGORY_IS_LETTER (gc))
+ {
+ found_letter = true;
+ break;
+ }
+ }
+ if (found_number && !found_letter)
+ horiz_dir = HB_DIRECTION_LTR;
+ }
+
/* TODO vertical:
* The only BTT vertical script is Ogham, but it's not clear to me whether OpenType
* Ogham fonts are supposed to be implemented BTT or not. Need to research that
@@ -1111,8 +1165,6 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
_hb_buffer_allocate_unicode_vars (c->buffer);
- c->buffer->clear_output ();
-
hb_ot_shape_initialize_masks (c);
hb_set_unicode_props (c->buffer);
hb_insert_dotted_circle (c->buffer, c->font);
@@ -1122,7 +1174,8 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
hb_ensure_native_direction (c->buffer);
if (c->plan->shaper->preprocess_text &&
- c->buffer->message(c->font, "start preprocess-text")) {
+ c->buffer->message(c->font, "start preprocess-text"))
+ {
c->plan->shaper->preprocess_text (c->plan, c->buffer, c->font);
(void) c->buffer->message(c->font, "end preprocess-text");
}
@@ -1164,7 +1217,7 @@ _hb_ot_shape (hb_shape_plan_t *shape_plan,
* @lookup_indexes: (out): The #hb_set_t set of lookups returned
*
* Computes the complete set of GSUB or GPOS lookups that are applicable
- * under a given @shape_plan.
+ * under a given @shape_plan.
*
* Since: 0.9.7
**/