summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/Font/ScaledFont.cpp
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2023-04-14 08:52:47 -0400
committerAndreas Kling <kling@serenityos.org>2023-04-15 15:24:50 +0200
commit55423b4ed06b4db1b61f862250d17f3407671117 (patch)
tree9ebb7bae0360b068af9857100a6d90ee2272eec9 /Userland/Libraries/LibGfx/Font/ScaledFont.cpp
parentc9404c3a63850719d79837a5c888382760b5d620 (diff)
downloadserenity-55423b4ed06b4db1b61f862250d17f3407671117.zip
LibGfx+Userland: Add width_rounded_up() helper
Diffstat (limited to 'Userland/Libraries/LibGfx/Font/ScaledFont.cpp')
-rw-r--r--Userland/Libraries/LibGfx/Font/ScaledFont.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Font/ScaledFont.cpp b/Userland/Libraries/LibGfx/Font/ScaledFont.cpp
index 6a9891fb01..441639bc97 100644
--- a/Userland/Libraries/LibGfx/Font/ScaledFont.cpp
+++ b/Userland/Libraries/LibGfx/Font/ScaledFont.cpp
@@ -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); }