Truly independent web browser
LibWeb: Give invisible glyphs no advance in upright text
Andreas Kling81e395ee1a65
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rsindex 63b62078841..014ece5dc49 100644--- a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs+++ b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs@@ -96,14 +96,15 @@ pub(crate) fn text_is_set_upright(writing_mode: u8, text_orientation: u8, code_p}/// Sets shaped glyphs upright: each of them takes one em along the inline axis, which runs downwards in the frame of-/// a vertical writing mode, while keeping its own horizontal width, which painting centers it within.+/// a vertical writing mode, while keeping its own horizontal width, which painting centers it within. Invisible+/// characters such as soft hyphens take no space.// FIXME: Use the vertical metrics of the font, where it has them.fn set_glyphs_upright(glyph_data: &mut line_box_fragment::GlyphData, inline_offset: f32, advance: f32) {let glyphs = glyph_data.glyphs.to_mut();let mut pen = inline_offset;let mut count = 0usize;for glyph in glyphs.iter_mut() {- if glyph.length_in_code_units != 0 {+ if glyph.length_in_code_units != 0 && glyph.should_paint {if count > 0 {pen += advance;}diff --git a/Tests/LibWeb/Layout/expected/upright-text-soft-hyphen-takes-no-space.txt b/Tests/LibWeb/Layout/expected/upright-text-soft-hyphen-takes-no-space.txtnew file mode 100644index 00000000000..37634ae9323--- /dev/null+++ b/Tests/LibWeb/Layout/expected/upright-text-soft-hyphen-takes-no-space.txt@@ -0,0 +1,12 @@+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 56 0+0+0] [BFC] children: not-inline+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 40 0+0+8] children: not-inline+ BlockContainer <div> at [8,8] [0+0+0 10 0+0+0] [0+0+0 40 0+0+0] [BFC] children: inline+ frag 0 from TextNode start: 0, length: 5, rect: [8,8 10x40] baseline: 8+ "abcd"+ TextNode <#text> (not painted)+ BlockContainer <(anonymous)> at [8,48] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: inline+ TextNode <#text> (not painted)++SC for Viewport<#document> [0,0 800x600] (z-index: auto)+ SC for BlockContainer<HTML> [0,0 800x56] (z-index: auto)diff --git a/Tests/LibWeb/Layout/input/upright-text-soft-hyphen-takes-no-space.html b/Tests/LibWeb/Layout/input/upright-text-soft-hyphen-takes-no-space.htmlnew file mode 100644index 00000000000..30adcd3c5a1--- /dev/null+++ b/Tests/LibWeb/Layout/input/upright-text-soft-hyphen-takes-no-space.html@@ -0,0 +1,13 @@+<!DOCTYPE html>+<style>+ @font-face {+ font-family: Ahem;+ src: url("../../Ref/data/fonts/Ahem.ttf");+ }+ div {+ font: 10px/10px Ahem;+ writing-mode: vertical-rl;+ text-orientation: upright;+ }+</style>+<div>ab­cd</div>