1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09: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
Notes: sideshowbarker 2024-07-19 00:28:56 +09:00
4 changed files with 17 additions and 4 deletions

View file

@ -105,6 +105,13 @@ public:
bool is_empty() const { return m_length == 0; }
size_t length() const { return m_length; }
size_t iterator_offset(const Utf32CodepointIterator& it) const
{
ASSERT(it.m_ptr >= m_code_points);
ASSERT(it.m_ptr < m_code_points + m_length);
return ((ptrdiff_t)it.m_ptr - (ptrdiff_t)m_code_points) / sizeof(u32);
}
Utf32View substring_view(size_t offset, size_t length) const
{
if (length == 0)