mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
LibWeb: Wrap font metrics into a struct
Rather than passing an increasingly-unwieldy number of font parameters individually to every function that resolves lengths, let's wrap them up. This is frustratingly close to being `Gfx::FontPixelMetrics`, but bitmap fonts cause issues: We choose the closest font to what the CSS requests, but that might have a wildly different size than what the page expects, so we have to fudge the numbers. No behaviour changes.
This commit is contained in:
parent
4a191875a9
commit
0679b4e0b9
14 changed files with 107 additions and 62 deletions
|
@ -167,11 +167,10 @@ bool MediaFeature::compare(HTML::Window const& window, MediaFeatureValue left, C
|
|||
|
||||
auto const& initial_font = window.associated_document().style_computer().initial_font();
|
||||
Gfx::FontPixelMetrics const& initial_font_metrics = initial_font.pixel_metrics();
|
||||
float initial_font_size = initial_font.presentation_size();
|
||||
float initial_line_height = initial_font_metrics.line_spacing();
|
||||
Length::FontMetrics font_metrics { static_cast<CSSPixels>(initial_font.presentation_size()), initial_font_metrics, initial_font_metrics.line_spacing() };
|
||||
|
||||
left_px = left.length().to_px(viewport_rect, initial_font_metrics, initial_font_size, initial_font_size, initial_line_height, initial_line_height);
|
||||
right_px = right.length().to_px(viewport_rect, initial_font_metrics, initial_font_size, initial_font_size, initial_line_height, initial_line_height);
|
||||
left_px = left.length().to_px(viewport_rect, font_metrics, font_metrics);
|
||||
right_px = right.length().to_px(viewport_rect, font_metrics, font_metrics);
|
||||
}
|
||||
|
||||
switch (comparison) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue