mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibGfx: Let's make it Font::width(Utf32View)
This commit is contained in:
parent
00b5614ce2
commit
bc6f469544
2 changed files with 7 additions and 6 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include <AK/BufferStream.h>
|
#include <AK/BufferStream.h>
|
||||||
#include <AK/MappedFile.h>
|
#include <AK/MappedFile.h>
|
||||||
#include <AK/StdLibExtras.h>
|
#include <AK/StdLibExtras.h>
|
||||||
|
#include <AK/Utf32View.h>
|
||||||
#include <AK/Utf8View.h>
|
#include <AK/Utf8View.h>
|
||||||
#include <AK/kmalloc.h>
|
#include <AK/kmalloc.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -255,13 +256,13 @@ int Font::width(const Utf8View& utf8) const
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Font::width(const u32* codepoints, size_t length) const
|
int Font::width(const Utf32View& view) const
|
||||||
{
|
{
|
||||||
if (length == 0)
|
if (view.length() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
int width = (length - 1) * glyph_spacing();
|
int width = (view.length() - 1) * glyph_spacing();
|
||||||
for (size_t i = 0; i < length; ++i)
|
for (size_t i = 0; i < view.length(); ++i)
|
||||||
width += glyph_or_emoji_width(codepoints[i]);
|
width += glyph_or_emoji_width(view.codepoints()[i]);
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
|
|
||||||
int width(const StringView&) const;
|
int width(const StringView&) const;
|
||||||
int width(const Utf8View&) const;
|
int width(const Utf8View&) const;
|
||||||
int width(const u32* codepoints, size_t) const;
|
int width(const Utf32View&) const;
|
||||||
|
|
||||||
String name() const { return m_name; }
|
String name() const { return m_name; }
|
||||||
void set_name(const StringView& name) { m_name = name; }
|
void set_name(const StringView& name) { m_name = name; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue