소스 검색

LibGfx: Make Font::width() return a float

Andreas Kling 2 년 전
부모
커밋
3407ab0fd1

+ 1 - 1
Userland/Applications/Browser/BookmarksBarWidget.cpp

@@ -196,7 +196,7 @@ void BookmarksBarWidget::model_did_update(unsigned)
         auto title = model()->index(item_index, 0).data().to_deprecated_string();
         auto title = model()->index(item_index, 0).data().to_deprecated_string();
         auto url = model()->index(item_index, 1).data().to_deprecated_string();
         auto url = model()->index(item_index, 1).data().to_deprecated_string();
 
 
-        Gfx::IntRect rect { width, 0, font().width(title) + 32, height() };
+        Gfx::IntRect rect { width, 0, static_cast<int>(ceilf(font().width(title))) + 32, height() };
 
 
         auto& button = add<GUI::Button>();
         auto& button = add<GUI::Button>();
         m_bookmarks.append(button);
         m_bookmarks.append(button);

+ 1 - 1
Userland/Applications/KeyboardMapper/KeyButton.cpp

@@ -41,7 +41,7 @@ void KeyButton::paint_event(GUI::PaintEvent& event)
     if (text().is_empty() || text().starts_with('\0'))
     if (text().is_empty() || text().starts_with('\0'))
         return;
         return;
 
 
-    Gfx::IntRect text_rect { 0, 0, font.width(text()), font.glyph_height() };
+    Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), font.glyph_height() };
     text_rect.align_within(key_cap_face_rect, Gfx::TextAlignment::Center);
     text_rect.align_within(key_cap_face_rect, Gfx::TextAlignment::Center);
 
 
     painter.draw_text(text_rect, text(), font, Gfx::TextAlignment::Center, Color::Black, Gfx::TextElision::Right);
     painter.draw_text(text_rect, text(), font, Gfx::TextAlignment::Center, Color::Black, Gfx::TextElision::Right);

+ 2 - 2
Userland/Applications/PixelPaint/Tools/TextTool.cpp

@@ -205,7 +205,7 @@ void TextTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event)
     painter.draw_scaled_bitmap(scaled_rect, text_bitmap, text_bitmap->rect(), 1.0);
     painter.draw_scaled_bitmap(scaled_rect, text_bitmap, text_bitmap->rect(), 1.0);
 
 
     // marching ants box
     // marching ants box
-    auto right_padding = m_selected_font->width("  "sv);
+    auto right_padding = static_cast<int>(ceilf(m_selected_font->width("  "sv)));
     m_ants_rect = Gfx::IntRect(text_location.translated(-4, -2), { scaled_rect.width() + 4 + right_padding, scaled_rect.height() + 4 });
     m_ants_rect = Gfx::IntRect(text_location.translated(-4, -2), { scaled_rect.width() + 4 + right_padding, scaled_rect.height() + 4 });
     m_editor->draw_marching_ants(painter, m_ants_rect);
     m_editor->draw_marching_ants(painter, m_ants_rect);
 
 
@@ -241,7 +241,7 @@ void TextTool::apply_text_to_layer()
     auto text_height = m_selected_font->preferred_line_height() * static_cast<int>(m_text_editor->line_count());
     auto text_height = m_selected_font->preferred_line_height() * static_cast<int>(m_text_editor->line_count());
 
 
     painter.set_font(*m_selected_font);
     painter.set_font(*m_selected_font);
-    auto text_rect = Gfx::Rect<int>(m_add_text_position, { text_width, text_height });
+    auto text_rect = Gfx::Rect<int>(m_add_text_position, { static_cast<int>(ceilf(text_width)), text_height });
     painter.draw_text(text_rect, demo_text, Gfx::TextAlignment::TopLeft, m_text_color);
     painter.draw_text(text_rect, demo_text, Gfx::TextAlignment::TopLeft, m_text_color);
     m_editor->did_complete_action(tool_name());
     m_editor->did_complete_action(tool_name());
     layer->did_modify_bitmap(text_rect);
     layer->did_modify_bitmap(text_rect);

+ 2 - 2
Userland/Applications/Welcome/WelcomeWidget.cpp

@@ -110,6 +110,6 @@ void WelcomeWidget::paint_event(GUI::PaintEvent& event)
 
 
     static auto font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular24.font"sv);
     static auto font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular24.font"sv);
     painter.draw_text({ 12, 4, 1, 30 }, "Welcome to "sv, *font, Gfx::TextAlignment::CenterLeft, palette().base_text());
     painter.draw_text({ 12, 4, 1, 30 }, "Welcome to "sv, *font, Gfx::TextAlignment::CenterLeft, palette().base_text());
-    painter.draw_text({ 12 + font->width("Welcome to "sv), 4, 1, 30 }, "Serenity"sv, font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().base_text());
-    painter.draw_text({ 12 + font->width("Welcome to "sv) + font->bold_variant().width("Serenity"sv), 4, 1, 30 }, "OS"sv, font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().base() == palette().window() ? palette().base_text() : palette().base());
+    painter.draw_text({ 12 + static_cast<int>(ceilf(font->width("Welcome to "sv))), 4, 1, 30 }, "Serenity"sv, font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().base_text());
+    painter.draw_text({ 12 + static_cast<int>(ceilf(font->width("Welcome to "sv))) + static_cast<int>(ceilf(font->bold_variant().width("Serenity"sv))), 4, 1, 30 }, "OS"sv, font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().base() == palette().window() ? palette().base_text() : palette().base());
 }
 }

+ 1 - 1
Userland/Games/BrickGame/BrickGame.cpp

@@ -499,7 +499,7 @@ void BrickGame::paint_cell(GUI::Painter& painter, Gfx::IntRect rect, bool is_on)
 
 
 void BrickGame::paint_text(GUI::Painter& painter, int row, DeprecatedString const& text)
 void BrickGame::paint_text(GUI::Painter& painter, int row, DeprecatedString const& text)
 {
 {
-    auto const text_width { font().width(text) };
+    auto const text_width = static_cast<int>(ceilf(font().width(text)));
     auto const entire_area_rect { frame_inner_rect() };
     auto const entire_area_rect { frame_inner_rect() };
     auto const margin = 4;
     auto const margin = 4;
     auto const glyph_height = font().glyph_height();
     auto const glyph_height = font().glyph_height();

+ 1 - 1
Userland/Games/ColorLines/ColorLines.cpp

@@ -211,7 +211,7 @@ void ColorLines::paint_event(GUI::PaintEvent& event)
 
 
     // Draw score
     // Draw score
     auto const score_text = MUST(String::formatted("{:05}"sv, m_score));
     auto const score_text = MUST(String::formatted("{:05}"sv, m_score));
-    auto text_width { m_score_font->width(score_text) };
+    auto text_width = static_cast<int>(ceilf(m_score_font->width(score_text)));
     auto const glyph_height = m_score_font->glyph_height();
     auto const glyph_height = m_score_font->glyph_height();
     auto const score_text_rect = Gfx::IntRect {
     auto const score_text_rect = Gfx::IntRect {
         frame_inner_rect().top_left().translated(text_margin),
         frame_inner_rect().top_left().translated(text_margin),

+ 1 - 1
Userland/Games/Hearts/ScoreCard.cpp

@@ -71,7 +71,7 @@ void ScoreCard::paint_event(GUI::PaintEvent& event)
         for (int score_index = 0; score_index < (int)player.scores.size(); score_index++) {
         for (int score_index = 0; score_index < (int)player.scores.size(); score_index++) {
             auto text_rect = cell_rect(player_index, 1 + score_index);
             auto text_rect = cell_rect(player_index, 1 + score_index);
             auto score_text = DeprecatedString::formatted("{}", player.scores[score_index]);
             auto score_text = DeprecatedString::formatted("{}", player.scores[score_index]);
-            auto score_text_width = font.width(score_text);
+            auto score_text_width = static_cast<int>(ceilf(font.width(score_text)));
             if (score_index != (int)player.scores.size() - 1) {
             if (score_index != (int)player.scores.size() - 1) {
                 painter.draw_line(
                 painter.draw_line(
                     { text_rect.left() + text_rect.width() / 2 - score_text_width / 2 - 3, text_rect.top() + font.glyph_height() / 2 },
                     { text_rect.left() + text_rect.width() / 2 - score_text_width / 2 - 3, text_rect.top() + font.glyph_height() / 2 },

+ 1 - 1
Userland/Libraries/LibCards/CardPainter.cpp

@@ -175,7 +175,7 @@ void CardPainter::paint_card_front(Gfx::Bitmap& bitmap, Cards::Suit suit, Cards:
     paint_rect.set_height(paint_rect.height() / 2);
     paint_rect.set_height(paint_rect.height() / 2);
     paint_rect.shrink(10, 6);
     paint_rect.shrink(10, 6);
 
 
-    auto text_rect = Gfx::IntRect { 4, 6, font.width("10"sv), font.glyph_height() };
+    auto text_rect = Gfx::IntRect { 4, 6, static_cast<int>(ceilf(font.width("10"sv))), font.glyph_height() };
     painter.draw_text(text_rect, card_rank_label(rank), font, Gfx::TextAlignment::Center, suit_color);
     painter.draw_text(text_rect, card_rank_label(rank), font, Gfx::TextAlignment::Center, suit_color);
 
 
     painter.draw_bitmap(
     painter.draw_bitmap(

+ 2 - 2
Userland/Libraries/LibGUI/Breadcrumbbar.cpp

@@ -109,10 +109,10 @@ void Breadcrumbbar::append_segment(DeprecatedString text, Gfx::Bitmap const* ico
     auto button_width = min(button_text_width + icon_width + icon_padding + 16, max_button_width);
     auto button_width = min(button_text_width + icon_width + icon_padding + 16, max_button_width);
     auto shrunken_width = icon_width + icon_padding + (icon ? 4 : 16);
     auto shrunken_width = icon_width + icon_padding + (icon ? 4 : 16);
 
 
-    button.set_max_size(button_width, 16 + 8);
+    button.set_max_size(static_cast<int>(ceilf(button_width)), 16 + 8);
     button.set_min_size(shrunken_width, 16 + 8);
     button.set_min_size(shrunken_width, 16 + 8);
 
 
-    Segment segment { icon, text, data, button_width, shrunken_width, button.make_weak_ptr<GUI::Button>() };
+    Segment segment { icon, text, data, static_cast<int>(ceilf(button_width)), shrunken_width, button.make_weak_ptr<GUI::Button>() };
 
 
     m_segments.append(move(segment));
     m_segments.append(move(segment));
     relayout();
     relayout();

+ 1 - 1
Userland/Libraries/LibGUI/Button.cpp

@@ -108,7 +108,7 @@ void Button::paint_event(PaintEvent& event)
         content_rect.set_width(content_rect.width() - m_icon->width() - icon_spacing());
         content_rect.set_width(content_rect.width() - m_icon->width() - icon_spacing());
     }
     }
 
 
-    Gfx::IntRect text_rect { 0, 0, font.width(text()), font.glyph_height() };
+    Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), font.glyph_height() };
     if (text_rect.width() > content_rect.width())
     if (text_rect.width() > content_rect.width())
         text_rect.set_width(content_rect.width());
         text_rect.set_width(content_rect.width());
     text_rect.align_within(content_rect, text_alignment());
     text_rect.align_within(content_rect, text_alignment());

+ 1 - 1
Userland/Libraries/LibGUI/GroupBox.cpp

@@ -43,7 +43,7 @@ void GroupBox::paint_event(PaintEvent& event)
     Gfx::StylePainter::paint_frame(painter, frame_rect, palette(), Gfx::FrameShape::Box, Gfx::FrameShadow::Sunken, 2);
     Gfx::StylePainter::paint_frame(painter, frame_rect, palette(), Gfx::FrameShape::Box, Gfx::FrameShadow::Sunken, 2);
 
 
     if (!m_title.is_empty()) {
     if (!m_title.is_empty()) {
-        Gfx::IntRect text_rect { 6, 1, font().width(m_title) + 6, font().glyph_height() };
+        Gfx::IntRect text_rect { 6, 1, static_cast<int>(ceilf(font().width(m_title) + 6)), font().glyph_height() };
         painter.fill_rect(text_rect, palette().button());
         painter.fill_rect(text_rect, palette().button());
         painter.draw_text(text_rect, m_title, Gfx::TextAlignment::Center, palette().button_text());
         painter.draw_text(text_rect, m_title, Gfx::TextAlignment::Center, palette().button_text());
     }
     }

+ 1 - 1
Userland/Libraries/LibGUI/HeaderView.cpp

@@ -272,7 +272,7 @@ void HeaderView::paint_horizontal(Painter& painter)
         painter.draw_text(text_rect, text, font(), section_data.alignment, palette().button_text());
         painter.draw_text(text_rect, text, font(), section_data.alignment, palette().button_text());
 
 
         if (is_key_column && (m_table_view.sort_order() != SortOrder::None)) {
         if (is_key_column && (m_table_view.sort_order() != SortOrder::None)) {
-            Gfx::IntPoint offset { text_rect.x() + font().width(text) + sorting_arrow_offset, sorting_arrow_offset };
+            Gfx::IntPoint offset { text_rect.x() + static_cast<int>(ceilf(font().width(text))) + sorting_arrow_offset, sorting_arrow_offset };
             auto coordinates = m_table_view.sort_order() == SortOrder::Ascending
             auto coordinates = m_table_view.sort_order() == SortOrder::Ascending
                 ? ascending_arrow_coordinates.span()
                 ? ascending_arrow_coordinates.span()
                 : descending_arrow_coordinates.span();
                 : descending_arrow_coordinates.span();

+ 1 - 1
Userland/Libraries/LibGUI/LinkLabel.cpp

@@ -79,7 +79,7 @@ void LinkLabel::paint_event(PaintEvent& event)
     GUI::Painter painter(*this);
     GUI::Painter painter(*this);
 
 
     if (m_hovered)
     if (m_hovered)
-        painter.draw_line({ 0, rect().bottom() }, { font().width(text()), rect().bottom() }, palette().link());
+        painter.draw_line({ 0, rect().bottom() }, { static_cast<int>(ceilf(font().width(text()))), rect().bottom() }, palette().link());
 
 
     if (is_focused())
     if (is_focused())
         painter.draw_focus_rect(text_rect(), palette().focus_outline());
         painter.draw_focus_rect(text_rect(), palette().focus_outline());

+ 1 - 1
Userland/Libraries/LibGUI/RadioButton.cpp

@@ -46,7 +46,7 @@ void RadioButton::paint_event(PaintEvent& event)
 
 
     Gfx::StylePainter::paint_radio_button(painter, circle_rect, palette(), is_checked(), is_being_pressed());
     Gfx::StylePainter::paint_radio_button(painter, circle_rect, palette(), is_checked(), is_being_pressed());
 
 
-    Gfx::IntRect text_rect { circle_rect.right() + 7, 0, font().width(text()), font().glyph_height() };
+    Gfx::IntRect text_rect { circle_rect.right() + 7, 0, static_cast<int>(ceilf(font().width(text()))), font().glyph_height() };
     text_rect.center_vertically_within(rect());
     text_rect.center_vertically_within(rect());
     paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft);
     paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft);
 
 

+ 1 - 1
Userland/Libraries/LibGUI/TabWidget.cpp

@@ -452,7 +452,7 @@ Gfx::IntRect TabWidget::close_button_rect(size_t index) const
 
 
 int TabWidget::TabData::width(Gfx::Font const& font) const
 int TabWidget::TabData::width(Gfx::Font const& font) const
 {
 {
-    auto width = 16 + font.width(title) + (icon ? (16 + 4) : 0);
+    auto width = 16 + static_cast<int>(ceilf(font.width(title))) + (icon ? (16 + 4) : 0);
     // NOTE: This needs to always be an odd number, because the button rect
     // NOTE: This needs to always be an odd number, because the button rect
     //       includes 3px of light and shadow on the left and right edges. If
     //       includes 3px of light and shadow on the left and right edges. If
     //       the button rect width is not an odd number, the area left for the
     //       the button rect width is not an odd number, the area left for the

+ 1 - 1
Userland/Libraries/LibGUI/TreeView.cpp

@@ -188,7 +188,7 @@ void TreeView::traverse_in_paint_order(Callback callback) const
             auto node_text = index.data().to_deprecated_string();
             auto node_text = index.data().to_deprecated_string();
             Gfx::IntRect rect = {
             Gfx::IntRect rect = {
                 x_offset, y_offset,
                 x_offset, y_offset,
-                icon_size() + icon_spacing() + text_padding() + font_for_index(index)->width(node_text) + text_padding(), row_height()
+                static_cast<int>(ceilf(icon_size() + icon_spacing() + text_padding() + font_for_index(index)->width(node_text) + text_padding())), row_height()
             };
             };
             Gfx::IntRect toggle_rect;
             Gfx::IntRect toggle_rect;
             if (row_count_at_index > 0) {
             if (row_count_at_index > 0) {

+ 3 - 3
Userland/Libraries/LibGfx/Font/BitmapFont.cpp

@@ -335,9 +335,9 @@ int BitmapFont::glyph_or_emoji_width_for_variable_width_font(u32 code_point) con
     return glyph_height() * emoji->width() / emoji->height();
     return glyph_height() * emoji->width() / emoji->height();
 }
 }
 
 
-int BitmapFont::width(StringView view) const { return unicode_view_width(Utf8View(view)); }
-int BitmapFont::width(Utf8View const& view) const { return unicode_view_width(view); }
-int BitmapFont::width(Utf32View const& view) const { return unicode_view_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); }
 
 
 template<typename T>
 template<typename T>
 ALWAYS_INLINE int BitmapFont::unicode_view_width(T const& view) const
 ALWAYS_INLINE int BitmapFont::unicode_view_width(T const& view) const

+ 3 - 3
Userland/Libraries/LibGfx/Font/BitmapFont.h

@@ -88,9 +88,9 @@ public:
         update_x_height();
         update_x_height();
     }
     }
 
 
-    int width(StringView) const override;
-    int width(Utf8View const&) const override;
-    int width(Utf32View const&) const override;
+    virtual float width(StringView) const override;
+    virtual float width(Utf8View const&) const override;
+    virtual float width(Utf32View const&) const override;
 
 
     DeprecatedString name() const override { return m_name; }
     DeprecatedString name() const override { return m_name; }
     void set_name(DeprecatedString name) { m_name = move(name); }
     void set_name(DeprecatedString name) { m_name = move(name); }

+ 3 - 3
Userland/Libraries/LibGfx/Font/Font.h

@@ -140,9 +140,9 @@ public:
     virtual u8 baseline() const = 0;
     virtual u8 baseline() const = 0;
     virtual u8 mean_line() const = 0;
     virtual u8 mean_line() const = 0;
 
 
-    virtual int width(StringView) const = 0;
-    virtual int width(Utf8View const&) const = 0;
-    virtual int width(Utf32View const&) const = 0;
+    virtual float width(StringView) const = 0;
+    virtual float width(Utf8View const&) const = 0;
+    virtual float width(Utf32View const&) const = 0;
 
 
     virtual DeprecatedString name() const = 0;
     virtual DeprecatedString name() const = 0;
 
 

+ 4 - 4
Userland/Libraries/LibGfx/Font/ScaledFont.cpp

@@ -10,12 +10,12 @@
 
 
 namespace Gfx {
 namespace Gfx {
 
 
-int ScaledFont::width(StringView view) const { return unicode_view_width(Utf8View(view)); }
-int ScaledFont::width(Utf8View const& view) const { return unicode_view_width(view); }
-int ScaledFont::width(Utf32View const& view) const { return unicode_view_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); }
 
 
 template<typename T>
 template<typename T>
-ALWAYS_INLINE int ScaledFont::unicode_view_width(T const& view) const
+ALWAYS_INLINE float ScaledFont::unicode_view_width(T const& view) const
 {
 {
     if (view.is_empty())
     if (view.is_empty())
         return 0;
         return 0;

+ 4 - 4
Userland/Libraries/LibGfx/Font/ScaledFont.h

@@ -54,9 +54,9 @@ public:
     virtual u8 glyph_fixed_width() const override;
     virtual u8 glyph_fixed_width() const override;
     virtual u8 baseline() const override { return m_point_height; }  // FIXME: Read from font
     virtual u8 baseline() const override { return m_point_height; }  // FIXME: Read from font
     virtual u8 mean_line() const override { return m_point_height; } // FIXME: Read from font
     virtual u8 mean_line() const override { return m_point_height; } // FIXME: Read from font
-    virtual int width(StringView) const override;
-    virtual int width(Utf8View const&) const override;
-    virtual int width(Utf32View const&) const override;
+    virtual float width(StringView) const override;
+    virtual float width(Utf8View const&) const override;
+    virtual float width(Utf32View const&) const override;
     virtual DeprecatedString name() const override { return DeprecatedString::formatted("{} {}", family(), variant()); }
     virtual DeprecatedString name() const override { return DeprecatedString::formatted("{} {}", family(), variant()); }
     virtual bool is_fixed_width() const override { return m_font->is_fixed_width(); }
     virtual bool is_fixed_width() const override { return m_font->is_fixed_width(); }
     virtual u8 glyph_spacing() const override { return 0; }
     virtual u8 glyph_spacing() const override { return 0; }
@@ -75,7 +75,7 @@ private:
     mutable HashMap<u32, RefPtr<Gfx::Bitmap>> m_cached_glyph_bitmaps;
     mutable HashMap<u32, RefPtr<Gfx::Bitmap>> m_cached_glyph_bitmaps;
 
 
     template<typename T>
     template<typename T>
-    int unicode_view_width(T const& view) const;
+    float unicode_view_width(T const& view) const;
 };
 };
 
 
 }
 }

+ 1 - 1
Userland/Libraries/LibGfx/Painter.cpp

@@ -2443,7 +2443,7 @@ void Gfx::Painter::draw_ui_text(Gfx::IntRect const& rect, StringView text, Gfx::
     Optional<size_t> underline_offset;
     Optional<size_t> underline_offset;
     auto name_to_draw = parse_ampersand_string(text, &underline_offset);
     auto name_to_draw = parse_ampersand_string(text, &underline_offset);
 
 
-    Gfx::IntRect text_rect { 0, 0, font.width(name_to_draw), static_cast<int>(ceilf(font.pixel_size())) };
+    Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(name_to_draw))), static_cast<int>(ceilf(font.pixel_size())) };
     text_rect.align_within(rect, text_alignment);
     text_rect.align_within(rect, text_alignment);
 
 
     draw_text(text_rect, name_to_draw, font, text_alignment, color);
     draw_text(text_rect, name_to_draw, font, text_alignment, color);

+ 1 - 1
Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp

@@ -205,7 +205,7 @@ void CanvasRenderingContext2D::fill_text(DeprecatedString const& text, float x,
     auto& drawing_state = this->drawing_state();
     auto& drawing_state = this->drawing_state();
 
 
     // FIXME: painter only supports integer rects for text right now, so this effectively chops off any fractional position
     // FIXME: painter only supports integer rects for text right now, so this effectively chops off any fractional position
-    auto text_rect = Gfx::IntRect(x, y, max_width.has_value() ? max_width.value() : painter->font().width(text), painter->font().pixel_size());
+    auto text_rect = Gfx::IntRect(x, y, max_width.has_value() ? static_cast<float>(max_width.value()) : painter->font().width(text), painter->font().pixel_size());
     auto transformed_rect = drawing_state.transform.map(text_rect);
     auto transformed_rect = drawing_state.transform.map(text_rect);
     painter->draw_text(transformed_rect, text, Gfx::TextAlignment::TopLeft, drawing_state.fill_style);
     painter->draw_text(transformed_rect, text, Gfx::TextAlignment::TopLeft, drawing_state.fill_style);
     did_draw(transformed_rect.to_type<float>());
     did_draw(transformed_rect.to_type<float>());

+ 1 - 1
Userland/Services/Taskbar/TaskbarButton.cpp

@@ -106,7 +106,7 @@ void TaskbarButton::paint_event(GUI::PaintEvent& event)
         content_rect.set_width(content_rect.width() - icon.width() - 4);
         content_rect.set_width(content_rect.width() - icon.width() - 4);
     }
     }
 
 
-    Gfx::IntRect text_rect { 0, 0, font.width(text()), font.glyph_height() };
+    Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), font.glyph_height() };
     if (text_rect.width() > content_rect.width())
     if (text_rect.width() > content_rect.width())
         text_rect.set_width(content_rect.width());
         text_rect.set_width(content_rect.width());
     text_rect.align_within(content_rect, text_alignment());
     text_rect.align_within(content_rect, text_alignment());

+ 1 - 1
Userland/Services/WindowServer/Overlays.cpp

@@ -243,7 +243,7 @@ void WindowGeometryOverlay::update_rect()
         } else {
         } else {
             m_label = window->rect().to_deprecated_string();
             m_label = window->rect().to_deprecated_string();
         }
         }
-        m_label_rect = Gfx::IntRect { 0, 0, wm.font().width(m_label) + 16, wm.font().glyph_height() + 10 };
+        m_label_rect = Gfx::IntRect { 0, 0, static_cast<int>(ceilf(wm.font().width(m_label))) + 16, wm.font().glyph_height() + 10 };
 
 
         auto rect = calculate_frame_rect(m_label_rect).centered_within(window->frame().rect());
         auto rect = calculate_frame_rect(m_label_rect).centered_within(window->frame().rect());
         auto desktop_rect = wm.desktop_rect(ScreenInput::the().cursor_location_screen());
         auto desktop_rect = wm.desktop_rect(ScreenInput::the().cursor_location_screen());