1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:27:45 +00:00

LibGfx+AK: Make text elision work with multi-byte characters

This was causing WindowServer and Taskbar to crash sometimes when the
stars aligned and we tried cutting off a string ending with "..." right
on top of an emoji. :^)
This commit is contained in:
Andreas Kling 2020-12-28 23:51:24 +01:00
parent 9af33e2e4b
commit 13594b7146
4 changed files with 17 additions and 4 deletions

View file

@ -76,10 +76,15 @@ public:
const unsigned char* bytes() const { return begin_ptr(); }
int byte_length() const { return m_string.length(); }
int byte_offset_of(const Utf8CodepointIterator&) const;
size_t byte_offset_of(const Utf8CodepointIterator&) const;
Utf8View substring_view(int byte_offset, int byte_length) const;
bool is_empty() const { return m_string.is_empty(); }
size_t iterator_offset(const Utf8CodepointIterator& it) const
{
return byte_offset_of(it);
}
bool validate(size_t& valid_bytes) const;
bool validate() const
{