From 661a8707f04e4e6d3dee0df19f34b3f37126b1cb Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 22 May 2021 11:55:08 +0200 Subject: [PATCH] LibCards: Fix alignment for the card labels Previously the code didn't take into account that the label for the "10" card is larger than for the other cards. --- Userland/Libraries/LibCards/Card.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibCards/Card.cpp b/Userland/Libraries/LibCards/Card.cpp index 218a7297338..fe8699234bc 100644 --- a/Userland/Libraries/LibCards/Card.cpp +++ b/Userland/Libraries/LibCards/Card.cpp @@ -96,7 +96,8 @@ Card::Card(Type type, uint8_t value) paint_rect.set_height(paint_rect.height() / 2); paint_rect.shrink(10, 6); - painter.draw_text(paint_rect, label, font, Gfx::TextAlignment::TopLeft, color()); + auto text_rect = Gfx::IntRect { 4, 6, font.width("10"), font.glyph_height() }; + painter.draw_text(text_rect, label, font, Gfx::TextAlignment::Center, color()); NonnullRefPtr symbol = s_diamond; switch (m_type) { @@ -117,7 +118,7 @@ Card::Card(Type type, uint8_t value) } painter.draw_bitmap( - { paint_rect.x() + (font.width(label) - symbol->size().width()) / 2, font.glyph_height() + paint_rect.y() + 3 }, + { text_rect.x() + (text_rect.width() - symbol->size().width()) / 2, text_rect.bottom() + 5 }, symbol, color()); for (int y = height / 2; y < height; ++y) {