1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:27:45 +00:00

LibWeb: Slightly decrease the font size used for media timestamps

The default scaled font is currently quite large on Ladybird. Decrease
it a bit to make more room for other elements.
This commit is contained in:
Timothy Flynn 2023-06-14 19:58:22 -04:00 committed by Andreas Kling
parent 54e674974e
commit 8cb0197eeb

View file

@ -170,14 +170,17 @@ DevicePixelRect MediaPaintable::paint_control_bar_timestamp(PaintContext& contex
auto timestamp = String::formatted("{} / {}", current_time, duration).release_value_but_fixme_should_propagate_errors(); auto timestamp = String::formatted("{} / {}", current_time, duration).release_value_but_fixme_should_propagate_errors();
auto const& scaled_font = layout_node().scaled_font(context); auto const& scaled_font = layout_node().scaled_font(context);
auto font = scaled_font.with_size(10);
if (!font)
font = scaled_font;
auto timestamp_size = static_cast<DevicePixels::Type>(ceilf(scaled_font.width(timestamp))); auto timestamp_size = static_cast<DevicePixels::Type>(ceilf(font->width(timestamp)));
if (timestamp_size > control_box_rect.width()) if (timestamp_size > control_box_rect.width())
return control_box_rect; return control_box_rect;
auto timestamp_rect = control_box_rect; auto timestamp_rect = control_box_rect;
timestamp_rect.set_width(timestamp_size); timestamp_rect.set_width(timestamp_size);
context.painter().draw_text(timestamp_rect.to_type<int>(), timestamp, scaled_font, Gfx::TextAlignment::CenterLeft, Color::White); context.painter().draw_text(timestamp_rect.to_type<int>(), timestamp, *font, Gfx::TextAlignment::CenterLeft, Color::White);
control_box_rect.take_from_left(timestamp_rect.width()); control_box_rect.take_from_left(timestamp_rect.width());
return control_box_rect; return control_box_rect;