mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
LibWeb: Use more precise font metrics when doing inline layout
We now position inline-level boxes based on ascent and descent metrics from the font in use. This makes our basic text layouts look a lot more like those produced by other browsers. :^) I've tried to match the terminology used by the CSS Inline Layout spec. This will regress Acid2 a little bit, and probably various other sites, but on the whole it's the direction we should be heading, so let's go.
This commit is contained in:
parent
fae8fde913
commit
6a4247bee9
4 changed files with 59 additions and 74 deletions
|
@ -451,8 +451,13 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const
|
|||
|
||||
for (auto& line_box : m_line_boxes) {
|
||||
for (auto& fragment : line_box.fragments()) {
|
||||
if (context.should_show_line_box_borders())
|
||||
context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Green);
|
||||
if (context.should_show_line_box_borders()) {
|
||||
auto fragment_absolute_rect = fragment.absolute_rect();
|
||||
context.painter().draw_rect(enclosing_int_rect(fragment_absolute_rect), Color::Green);
|
||||
context.painter().draw_line(
|
||||
fragment_absolute_rect.top_left().translated(0, fragment.baseline()).to_rounded<int>(),
|
||||
fragment_absolute_rect.top_right().translated(0, fragment.baseline()).to_rounded<int>(), Color::Red);
|
||||
}
|
||||
if (is<Layout::TextNode>(fragment.layout_node()))
|
||||
paint_text_fragment(context, static_cast<Layout::TextNode const&>(fragment.layout_node()), fragment, phase);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue