diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2023-02-13 10:44:33 +0100 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2023-04-03 09:13:48 +0200 |
commit | abc13dbd0b5e3c12de3d52ea3b843e7c607bdf1d (patch) | |
tree | 4f93886fa78b19258c366b007fce91a2f8369857 /thirdparty/harfbuzz/src/hb-utf.hh | |
parent | df7834ac96398da0cb6b09f77ec010d4dff467f7 (diff) | |
download | redot-engine-abc13dbd0b5e3c12de3d52ea3b843e7c607bdf1d.tar.gz |
Update HarfBuzz to 7.1.0
Diffstat (limited to 'thirdparty/harfbuzz/src/hb-utf.hh')
-rw-r--r-- | thirdparty/harfbuzz/src/hb-utf.hh | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/thirdparty/harfbuzz/src/hb-utf.hh b/thirdparty/harfbuzz/src/hb-utf.hh index ff5712d16d..1120bd1ccc 100644 --- a/thirdparty/harfbuzz/src/hb-utf.hh +++ b/thirdparty/harfbuzz/src/hb-utf.hh @@ -35,6 +35,7 @@ struct hb_utf8_t { typedef uint8_t codepoint_t; + static constexpr unsigned max_len = 4; static const codepoint_t * next (const codepoint_t *text, @@ -182,6 +183,7 @@ struct hb_utf16_xe_t { static_assert (sizeof (TCodepoint) == 2, ""); typedef TCodepoint codepoint_t; + static constexpr unsigned max_len = 2; static const codepoint_t * next (const codepoint_t *text, @@ -290,6 +292,7 @@ struct hb_utf32_xe_t { static_assert (sizeof (TCodepoint) == 4, ""); typedef TCodepoint codepoint_t; + static constexpr unsigned max_len = 1; static const TCodepoint * next (const TCodepoint *text, @@ -348,6 +351,7 @@ typedef hb_utf32_xe_t<uint32_t, false> hb_utf32_novalidate_t; struct hb_latin1_t { typedef uint8_t codepoint_t; + static constexpr unsigned max_len = 1; static const codepoint_t * next (const codepoint_t *text, @@ -399,12 +403,13 @@ struct hb_latin1_t struct hb_ascii_t { typedef uint8_t codepoint_t; + static constexpr unsigned max_len = 1; static const codepoint_t * next (const codepoint_t *text, const codepoint_t *end HB_UNUSED, hb_codepoint_t *unicode, - hb_codepoint_t replacement HB_UNUSED) + hb_codepoint_t replacement) { *unicode = *text++; if (*unicode >= 0x0080u) @@ -450,4 +455,27 @@ struct hb_ascii_t } }; +template <typename utf_t> +static inline const typename utf_t::codepoint_t * +hb_utf_offset_to_pointer (const typename utf_t::codepoint_t *start, + signed offset) +{ + hb_codepoint_t unicode; + + while (offset-- > 0) + start = utf_t::next (start, + start + utf_t::max_len, + &unicode, + HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT); + + while (offset++ < 0) + start = utf_t::prev (start, + start - utf_t::max_len, + &unicode, + HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT); + + return start; +} + + #endif /* HB_UTF_HH */ |