Skip to content

Commit

Permalink
LibWeb/CSS: Unit test: layout text with invalid font
Browse files Browse the repository at this point in the history
- Before: the default emoji font was picked up. The text was split
          into five fragments (3 text; 2 whitespace) and the whitespace
          was probably extended to match the font metrics.
- After: the whole text is layed out into one fragment.

NOTE:
- This test may not work on the Apple platform: expect font metrics for
  the default emoji font to be different from Ubuntu, although the
  layout should be the same.
- The test works reliably in the test runner `headless-browser -R`,
  however, it generates different layout metrics compared to running
  stand-alone in dump mode `headless-browser -d`.
  • Loading branch information
manuel-za committed Dec 22, 2024
1 parent d75a085 commit 4045be8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Tests/LibWeb/Layout/expected/invalid-font-name.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x17 children: inline
frag 0 from TextNode start: 0, length: 19, rect: [8,8 142.140625x17] baseline: 13.296875
"Well hello friends!"
TextNode <#text>

ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,8 784x17]
TextPaintable (TextNode<#text>)

13 changes: 13 additions & 0 deletions Tests/LibWeb/Layout/input/invalid-font-name.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<style>
html { font-family: lololol; }
</style>
<!--
This should just show in one full fragment in a TextNode.
Before, when the font 'lololol' was not found, the default emoji font was picked for rendering.
The text was split into five separate fragments.
NOTE:
- this may fail CI on Apple (the default font metrics may be different).
- the layout metrics reported by `headless-browser -R` vs. `headless-browser -d` are different.
-->
Well hello friends!

0 comments on commit 4045be8

Please sign in to comment.