Index: third_party/harfbuzz-ng/src/hb-ot-layout.cc |
diff --git a/third_party/harfbuzz-ng/src/hb-ot-layout.cc b/third_party/harfbuzz-ng/src/hb-ot-layout.cc |
index 9fc88f6c86220d70e1cca25e39de51bb3c602d57..adf232bf11908fba6b3723b9bfc13526c4186e1a 100644 |
--- a/third_party/harfbuzz-ng/src/hb-ot-layout.cc |
+++ b/third_party/harfbuzz-ng/src/hb-ot-layout.cc |
@@ -771,12 +771,6 @@ hb_ot_layout_substitute_start (hb_font_t *font, hb_buffer_t *buffer) |
OT::GSUB::substitute_start (font, buffer); |
} |
-void |
-hb_ot_layout_substitute_finish (hb_font_t *font, hb_buffer_t *buffer) |
-{ |
- OT::GSUB::substitute_finish (font, buffer); |
-} |
- |
/** |
* hb_ot_layout_lookup_substitute_closure: |
* |
@@ -811,9 +805,15 @@ hb_ot_layout_position_start (hb_font_t *font, hb_buffer_t *buffer) |
} |
void |
-hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer) |
+hb_ot_layout_position_finish_advances (hb_font_t *font, hb_buffer_t *buffer) |
+{ |
+ OT::GPOS::position_finish_advances (font, buffer); |
+} |
+ |
+void |
+hb_ot_layout_position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer) |
{ |
- OT::GPOS::position_finish (font, buffer); |
+ OT::GPOS::position_finish_offsets (font, buffer); |
} |
/** |
@@ -902,20 +902,79 @@ struct GPOSProxy |
}; |
-template <typename Obj> |
+struct hb_get_subtables_context_t : |
+ OT::hb_dispatch_context_t<hb_get_subtables_context_t, hb_void_t, HB_DEBUG_APPLY> |
+{ |
+ template <typename Type> |
+ static inline bool apply_to (const void *obj, OT::hb_apply_context_t *c) |
+ { |
+ const Type *typed_obj = (const Type *) obj; |
+ return typed_obj->apply (c); |
+ } |
+ |
+ typedef bool (*hb_apply_func_t) (const void *obj, OT::hb_apply_context_t *c); |
+ |
+ struct hb_applicable_t |
+ { |
+ inline void init (const void *obj_, hb_apply_func_t apply_func_) |
+ { |
+ obj = obj_; |
+ apply_func = apply_func_; |
+ } |
+ |
+ inline bool apply (OT::hb_apply_context_t *c) const { return apply_func (obj, c); } |
+ |
+ private: |
+ const void *obj; |
+ hb_apply_func_t apply_func; |
+ }; |
+ |
+ typedef hb_auto_array_t<hb_applicable_t> array_t; |
+ |
+ /* Dispatch interface. */ |
+ inline const char *get_name (void) { return "GET_SUBTABLES"; } |
+ template <typename T> |
+ inline return_t dispatch (const T &obj) |
+ { |
+ hb_applicable_t *entry = array.push(); |
+ if (likely (entry)) |
+ entry->init (&obj, apply_to<T>); |
+ return HB_VOID; |
+ } |
+ static return_t default_return_value (void) { return HB_VOID; } |
+ bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return false; } |
+ |
+ hb_get_subtables_context_t (array_t &array_) : |
+ array (array_), |
+ debug_depth (0) {} |
+ |
+ array_t &array; |
+ unsigned int debug_depth; |
+}; |
+ |
static inline bool |
apply_forward (OT::hb_apply_context_t *c, |
- const Obj &obj, |
- const hb_ot_layout_lookup_accelerator_t &accel) |
+ const hb_ot_layout_lookup_accelerator_t &accel, |
+ const hb_get_subtables_context_t::array_t &subtables) |
{ |
bool ret = false; |
hb_buffer_t *buffer = c->buffer; |
while (buffer->idx < buffer->len && !buffer->in_error) |
{ |
+ bool applied = false; |
if (accel.may_have (buffer->cur().codepoint) && |
(buffer->cur().mask & c->lookup_mask) && |
- c->check_glyph_property (&buffer->cur(), c->lookup_props) && |
- obj.apply (c)) |
+ c->check_glyph_property (&buffer->cur(), c->lookup_props)) |
+ { |
+ for (unsigned int i = 0; i < subtables.len; i++) |
+ if (subtables[i].apply (c)) |
+ { |
+ applied = true; |
+ break; |
+ } |
+ } |
+ |
+ if (applied) |
ret = true; |
else |
buffer->next_glyph (); |
@@ -923,11 +982,10 @@ apply_forward (OT::hb_apply_context_t *c, |
return ret; |
} |
-template <typename Obj> |
static inline bool |
apply_backward (OT::hb_apply_context_t *c, |
- const Obj &obj, |
- const hb_ot_layout_lookup_accelerator_t &accel) |
+ const hb_ot_layout_lookup_accelerator_t &accel, |
+ const hb_get_subtables_context_t::array_t &subtables) |
{ |
bool ret = false; |
hb_buffer_t *buffer = c->buffer; |
@@ -935,9 +993,15 @@ apply_backward (OT::hb_apply_context_t *c, |
{ |
if (accel.may_have (buffer->cur().codepoint) && |
(buffer->cur().mask & c->lookup_mask) && |
- c->check_glyph_property (&buffer->cur(), c->lookup_props) && |
- obj.apply (c)) |
- ret = true; |
+ c->check_glyph_property (&buffer->cur(), c->lookup_props)) |
+ { |
+ for (unsigned int i = 0; i < subtables.len; i++) |
+ if (subtables[i].apply (c)) |
+ { |
+ ret = true; |
+ break; |
+ } |
+ } |
/* The reverse lookup doesn't "advance" cursor (for good reason). */ |
buffer->idx--; |
@@ -946,26 +1010,6 @@ apply_backward (OT::hb_apply_context_t *c, |
return ret; |
} |
-struct hb_apply_forward_context_t : |
- OT::hb_dispatch_context_t<hb_apply_forward_context_t, bool, HB_DEBUG_APPLY> |
-{ |
- inline const char *get_name (void) { return "APPLY_FWD"; } |
- template <typename T> |
- inline return_t dispatch (const T &obj) { return apply_forward (c, obj, accel); } |
- static return_t default_return_value (void) { return false; } |
- bool stop_sublookup_iteration (return_t r HB_UNUSED) const { return true; } |
- |
- hb_apply_forward_context_t (OT::hb_apply_context_t *c_, |
- const hb_ot_layout_lookup_accelerator_t &accel_) : |
- c (c_), |
- accel (accel_), |
- debug_depth (0) {} |
- |
- OT::hb_apply_context_t *c; |
- const hb_ot_layout_lookup_accelerator_t &accel; |
- unsigned int debug_depth; |
-}; |
- |
template <typename Proxy> |
static inline void |
apply_string (OT::hb_apply_context_t *c, |
@@ -979,6 +1023,10 @@ apply_string (OT::hb_apply_context_t *c, |
c->set_lookup_props (lookup.get_props ()); |
+ hb_get_subtables_context_t::array_t subtables; |
+ hb_get_subtables_context_t c_get_subtables (subtables); |
+ lookup.dispatch (&c_get_subtables); |
+ |
if (likely (!lookup.is_reverse ())) |
{ |
/* in/out forward substitution/positioning */ |
@@ -987,13 +1035,7 @@ apply_string (OT::hb_apply_context_t *c, |
buffer->idx = 0; |
bool ret; |
- if (lookup.get_subtable_count () == 1) |
- { |
- hb_apply_forward_context_t c_forward (c, accel); |
- ret = lookup.dispatch (&c_forward); |
- } |
- else |
- ret = apply_forward (c, lookup, accel); |
+ ret = apply_forward (c, accel, subtables); |
if (ret) |
{ |
if (!Proxy::inplace) |
@@ -1009,7 +1051,7 @@ apply_string (OT::hb_apply_context_t *c, |
buffer->remove_output (); |
buffer->idx = buffer->len - 1; |
- apply_backward (c, lookup, accel); |
+ apply_backward (c, accel, subtables); |
} |
} |