From e4da38020021a92afa4062ed676f286945070dc4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 Nov 2017 17:14:27 -0800 Subject: [PATCH] [coretext/uniscribe/directwrite/graphite/fallback] Update for unsafe-to-break Fixes https://github.com/behdad/harfbuzz/issues/615 We'll see which bots I broke. --- src/hb-buffer-private.hh | 17 +++++++++++++++-- src/hb-coretext.cc | 2 ++ src/hb-directwrite.cc | 3 +-- src/hb-fallback-shape.cc | 2 ++ src/hb-graphite2.cc | 2 ++ src/hb-uniscribe.cc | 2 ++ 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh index 0b8d7c89f..4913da6a5 100644 --- a/src/hb-buffer-private.hh +++ b/src/hb-buffer-private.hh @@ -305,7 +305,7 @@ struct hb_buffer_t { info.cluster = cluster; } - int + inline int _unsafe_to_break_find_min_cluster (const hb_glyph_info_t *info, unsigned int start, unsigned int end, unsigned int cluster) const @@ -314,7 +314,7 @@ struct hb_buffer_t { cluster = MIN (cluster, info[i].cluster); return cluster; } - void + inline void _unsafe_to_break_set_mask (hb_glyph_info_t *info, unsigned int start, unsigned int end, unsigned int cluster) @@ -326,6 +326,19 @@ struct hb_buffer_t { info[i].mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK; } } + + inline void + unsafe_to_break_all (void) + { + for (unsigned int i = 0; i < len; i++) + info[i].mask |= HB_GLYPH_FLAG_UNSAFE_TO_BREAK; + } + inline void + safe_to_break_all (void) + { + for (unsigned int i = 0; i < len; i++) + info[i].mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK; + } }; diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc index 90c9cd397..86ca17fb2 100644 --- a/src/hb-coretext.cc +++ b/src/hb-coretext.cc @@ -1262,6 +1262,8 @@ resize_and_retry: } } + buffer->unsafe_to_break_all (); + #undef FAIL fail: diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc index 25749de8c..0674ef9bc 100644 --- a/src/hb-directwrite.cc +++ b/src/hb-directwrite.cc @@ -927,8 +927,7 @@ hb_directwrite_shape_experimental_width(hb_font_t *font, hb_bool_t res = _hb_directwrite_shape_full (shape_plan, font, buffer, features, num_features, width); - if (res) - buffer->content_type = HB_BUFFER_CONTENT_TYPE_GLYPHS; + buffer->unsafe_to_break_all (); return res; } diff --git a/src/hb-fallback-shape.cc b/src/hb-fallback-shape.cc index 4b60c6c34..3f09c3f53 100644 --- a/src/hb-fallback-shape.cc +++ b/src/hb-fallback-shape.cc @@ -143,5 +143,7 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED, if (HB_DIRECTION_IS_BACKWARD (direction)) hb_buffer_reverse (buffer); + buffer->safe_to_break_all (); + return true; } diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc index 531c2ad6e..62aaae9e8 100644 --- a/src/hb-graphite2.cc +++ b/src/hb-graphite2.cc @@ -416,5 +416,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan, if (feats) gr_featureval_destroy (feats); gr_seg_destroy (seg); + buffer->unsafe_to_break_all (); + return true; } diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc index 484134570..0b0bad58d 100644 --- a/src/hb-uniscribe.cc +++ b/src/hb-uniscribe.cc @@ -1032,6 +1032,8 @@ retry: if (backward) hb_buffer_reverse (buffer); + buffer->unsafe_to_break_all (); + /* Wow, done! */ return true; }