[buffer] Add ::reverse_groups()
This commit is contained in:
parent
4cd96e73e4
commit
1b78e04c78
|
@ -395,29 +395,6 @@ hb_buffer_t::set_masks (hb_mask_t value,
|
||||||
info[i].mask = (info[i].mask & not_mask) | value;
|
info[i].mask = (info[i].mask & not_mask) | value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
hb_buffer_t::reverse_clusters ()
|
|
||||||
{
|
|
||||||
unsigned int i, start, count, last_cluster;
|
|
||||||
|
|
||||||
if (unlikely (!len))
|
|
||||||
return;
|
|
||||||
|
|
||||||
reverse ();
|
|
||||||
|
|
||||||
count = len;
|
|
||||||
start = 0;
|
|
||||||
last_cluster = info[0].cluster;
|
|
||||||
for (i = 1; i < count; i++) {
|
|
||||||
if (last_cluster != info[i].cluster) {
|
|
||||||
reverse_range (start, i);
|
|
||||||
start = i;
|
|
||||||
last_cluster = info[i].cluster;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reverse_range (start, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
hb_buffer_t::merge_clusters_impl (unsigned int start,
|
hb_buffer_t::merge_clusters_impl (unsigned int start,
|
||||||
unsigned int end)
|
unsigned int end)
|
||||||
|
|
|
@ -209,7 +209,31 @@ struct hb_buffer_t
|
||||||
}
|
}
|
||||||
void reverse () { reverse_range (0, len); }
|
void reverse () { reverse_range (0, len); }
|
||||||
|
|
||||||
HB_INTERNAL void reverse_clusters ();
|
template <typename FuncType>
|
||||||
|
void reverse_groups (const FuncType& group)
|
||||||
|
{
|
||||||
|
if (unlikely (!len))
|
||||||
|
return;
|
||||||
|
|
||||||
|
reverse ();
|
||||||
|
|
||||||
|
unsigned count = len;
|
||||||
|
unsigned start = 0;
|
||||||
|
unsigned i;
|
||||||
|
for (i = 1; i < count; i++)
|
||||||
|
{
|
||||||
|
if (!group (info[i - 1], info[i]))
|
||||||
|
{
|
||||||
|
reverse_range (start, i);
|
||||||
|
start = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reverse_range (start, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reverse_clusters ()
|
||||||
|
{ reverse_groups ([] (const hb_glyph_info_t& a, const hb_glyph_info_t& b) -> bool { return a.cluster == b.cluster; }); }
|
||||||
|
|
||||||
HB_INTERNAL void guess_segment_properties ();
|
HB_INTERNAL void guess_segment_properties ();
|
||||||
|
|
||||||
HB_INTERNAL void swap_buffers ();
|
HB_INTERNAL void swap_buffers ();
|
||||||
|
|
Loading…
Reference in New Issue