1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

LibGfx: Add Font::width(u32* codepoints, size_t)

This allows you to measure the width of a UTF-32 sequence.
This commit is contained in:
Andreas Kling 2020-05-17 17:45:12 +02:00
parent 4ced126704
commit 35875b68f5
Notes: sideshowbarker 2024-07-19 06:33:27 +09:00
2 changed files with 11 additions and 0 deletions

View file

@ -255,4 +255,14 @@ int Font::width(const Utf8View& utf8) const
return width;
}
int Font::width(const u32* codepoints, size_t length) const
{
if (length == 0)
return 0;
int width = (length - 1) * glyph_spacing();
for (size_t i = 0; i < length; ++i)
width += glyph_or_emoji_width(codepoints[i]);
return width;
}
}