mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:07:34 +00:00
LibGfx: Make Font::width() return a float
This commit is contained in:
parent
b9d2b8f7b2
commit
3407ab0fd1
25 changed files with 40 additions and 40 deletions
|
@ -196,7 +196,7 @@ void BookmarksBarWidget::model_did_update(unsigned)
|
|||
auto title = model()->index(item_index, 0).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>();
|
||||
m_bookmarks.append(button);
|
||||
|
|
|
@ -41,7 +41,7 @@ void KeyButton::paint_event(GUI::PaintEvent& event)
|
|||
if (text().is_empty() || text().starts_with('\0'))
|
||||
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);
|
||||
|
||||
painter.draw_text(text_rect, text(), font, Gfx::TextAlignment::Center, Color::Black, Gfx::TextElision::Right);
|
||||
|
|
|
@ -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);
|
||||
|
||||
// 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_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());
|
||||
|
||||
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);
|
||||
m_editor->did_complete_action(tool_name());
|
||||
layer->did_modify_bitmap(text_rect);
|
||||
|
|
|
@ -110,6 +110,6 @@ void WelcomeWidget::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
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 + 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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue