mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 18:27:36 +00:00
LibGfx+Userland: Add width_rounded_up() helper
This commit is contained in:
parent
c9404c3a63
commit
55423b4ed0
21 changed files with 34 additions and 19 deletions
|
@ -336,6 +336,11 @@ float BitmapFont::glyph_or_emoji_width(Utf32CodePointIterator& it) const
|
|||
return glyph_or_emoji_width_impl(*this, it);
|
||||
}
|
||||
|
||||
int BitmapFont::width_rounded_up(StringView view) const
|
||||
{
|
||||
return static_cast<int>(ceilf(width(view)));
|
||||
}
|
||||
|
||||
float BitmapFont::width(StringView view) const { return unicode_view_width(Utf8View(view)); }
|
||||
float BitmapFont::width(Utf8View const& view) const { return unicode_view_width(view); }
|
||||
float BitmapFont::width(Utf32View const& view) const { return unicode_view_width(view); }
|
||||
|
|
|
@ -97,6 +97,8 @@ public:
|
|||
virtual float width(Utf8View const&) const override;
|
||||
virtual float width(Utf32View const&) const override;
|
||||
|
||||
virtual int width_rounded_up(StringView) const override;
|
||||
|
||||
DeprecatedString name() const override { return m_name; }
|
||||
void set_name(DeprecatedString name) { m_name = move(name); }
|
||||
|
||||
|
|
|
@ -196,6 +196,8 @@ public:
|
|||
virtual float width(Utf8View const&) const = 0;
|
||||
virtual float width(Utf32View const&) const = 0;
|
||||
|
||||
virtual int width_rounded_up(StringView) const = 0;
|
||||
|
||||
virtual DeprecatedString name() const = 0;
|
||||
|
||||
virtual bool is_fixed_width() const = 0;
|
||||
|
|
|
@ -36,6 +36,11 @@ ScaledFont::ScaledFont(NonnullRefPtr<VectorFont> font, float point_width, float
|
|||
};
|
||||
}
|
||||
|
||||
int ScaledFont::width_rounded_up(StringView view) const
|
||||
{
|
||||
return static_cast<int>(ceilf(width(view)));
|
||||
}
|
||||
|
||||
float ScaledFont::width(StringView view) const { return unicode_view_width(Utf8View(view)); }
|
||||
float ScaledFont::width(Utf8View const& view) const { return unicode_view_width(view); }
|
||||
float ScaledFont::width(Utf32View const& view) const { return unicode_view_width(view); }
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
virtual float width(StringView) const override;
|
||||
virtual float width(Utf8View const&) const override;
|
||||
virtual float width(Utf32View const&) const override;
|
||||
virtual int width_rounded_up(StringView) const override;
|
||||
virtual DeprecatedString name() const override { return DeprecatedString::formatted("{} {}", family(), variant()); }
|
||||
virtual bool is_fixed_width() const override { return m_font->is_fixed_width(); }
|
||||
virtual u8 glyph_spacing() const override { return 0; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue