mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +00: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:
parent
4ced126704
commit
35875b68f5
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ public:
|
|||
|
||||
int width(const StringView&) const;
|
||||
int width(const Utf8View&) const;
|
||||
int width(const u32* codepoints, size_t) const;
|
||||
|
||||
String name() const { return m_name; }
|
||||
void set_name(const StringView& name) { m_name = name; }
|
||||
|
|
Loading…
Reference in a new issue