diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index fddda2330..e09dee77f 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -387,9 +387,11 @@ hb_buffer_t::clear_positions () hb_memset (pos, 0, sizeof (pos[0]) * len); } -void +bool hb_buffer_t::sync () { + bool ret = false; + assert (have_output); assert (idx <= len); @@ -403,12 +405,36 @@ hb_buffer_t::sync () info = out_info; } len = out_len; + ret = true; reset: have_output = false; out_len = 0; out_info = info; idx = 0; + + return ret; +} + +void +hb_buffer_t::sync_so_far () +{ + bool had_output = have_output; + unsigned out_i = out_len; + unsigned i = idx; + + if (sync ()) + idx = out_i; + else + idx = i; + + if (had_output) + { + have_output = true; + out_len = idx; + } + + assert (idx <= len); } bool diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 6ca78f28d..5ad273ce8 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -288,7 +288,8 @@ struct hb_buffer_t HB_INTERNAL void guess_segment_properties (); - HB_INTERNAL void sync (); + HB_INTERNAL bool sync (); + HB_INTERNAL void sync_so_far (); HB_INTERNAL void clear_output (); HB_INTERNAL void clear_positions ();