From a5cc76216e08481a6f3614574a8ee498e5800afa Mon Sep 17 00:00:00 2001 From: Sam Varshavchik Date: Sun, 6 Dec 2020 22:35:33 -0500 Subject: courier-unicode: partial logical reordering. --- unicode/unicodecpp.C | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'unicode/unicodecpp.C') diff --git a/unicode/unicodecpp.C b/unicode/unicodecpp.C index 5677b86..3ef3b05 100644 --- a/unicode/unicodecpp.C +++ b/unicode/unicodecpp.C @@ -806,16 +806,24 @@ int unicode::bidi_logical_order(std::u32string &string, std::vector &levels, unicode_bidi_level_t paragraph_embedding, const std::function - &lambda) + &lambda, + size_t starting_pos, + size_t n) { - if (string.size() != levels.size()) + auto s=string.size(); + + if (s != levels.size()) return -1; - if (string.empty()) + if (starting_pos >= s) return 0; + if (n > s-starting_pos) + n=s-starting_pos; + cb_wrapper cb{lambda}; - unicode_bidi_logical_order(&string[0], &levels[0], string.size(), + unicode_bidi_logical_order(&string[starting_pos], + &levels[starting_pos], n, paragraph_embedding, &reorder_callback, reinterpret_cast(&cb)); @@ -826,13 +834,20 @@ int unicode::bidi_logical_order(std::u32string &string, void unicode::bidi_logical_order(std::vector &levels, unicode_bidi_level_t paragraph_embedding, const std::function - &lambda) + &lambda, + size_t starting_pos, + size_t n) { - if (levels.size() == 0) + auto s=levels.size(); + + if (starting_pos >= s) return; + if (n > s-starting_pos) + n=s-starting_pos; + cb_wrapper cb{lambda}; - unicode_bidi_logical_order(NULL, &levels[0], levels.size(), + unicode_bidi_logical_order(NULL, &levels[starting_pos], n, paragraph_embedding, &reorder_callback, reinterpret_cast(&cb)); -- cgit v1.2.3