Skip to content

Truly independent web browser

LibWeb: Draw text-overflow’s periods in a font that has a period

sideshowbarker0c73e19fa18b
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
index 64a33c2666c..e6a9c5adfe9 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
@@ -93,7 +93,13 @@ impl TextOverflowEllipsis {
} else {
&THREE_PERIODS
};
- let font = first_available_font.clone();
+ // NB: The periods come from whichever font of the block has a period for them, which needn't be its first
+ // available font: That one can be a font whose unicode-range leaves the period out.
+ let code_point = u32::from(text[0]);
+ let font = font_list.font_for_code_point(
+ code_point,
+ libgfx_rust::font::emoji_presentation_for_code_point(code_point, None),
+ );
let shaped = libgfx_rust::text_layout::shape_text(
&font,
text,
diff --git a/Tests/LibWeb/Ref/expected/text-overflow-ellipsis-periods-from-font-with-a-period-ref.html b/Tests/LibWeb/Ref/expected/text-overflow-ellipsis-periods-from-font-with-a-period-ref.html
new file mode 100644
index 00000000000..8d6d75a11c3
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/text-overflow-ellipsis-periods-from-font-with-a-period-ref.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+ @font-face { font-family: CapitalsAndSpace; src: url("../data/fonts/Ahem.ttf"); unicode-range: U+0020, U+0041-005A; }
+ @font-face { font-family: FiraCode; src: url("../../Assets/FiraCode-Latin.woff2"); }
+ body { margin: 0; }
+ div { width: 200px; font: 20px/30px CapitalsAndSpace, FiraCode; overflow: hidden; white-space: nowrap; }
+</style>
+<div>ABCDEFGH...</div>
diff --git a/Tests/LibWeb/Ref/input/text-overflow-ellipsis-periods-from-font-with-a-period.html b/Tests/LibWeb/Ref/input/text-overflow-ellipsis-periods-from-font-with-a-period.html
new file mode 100644
index 00000000000..2252a7ea2a7
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/text-overflow-ellipsis-periods-from-font-with-a-period.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<link rel="match" href="../expected/text-overflow-ellipsis-periods-from-font-with-a-period-ref.html">
+<style>
+ @font-face { font-family: CapitalsAndSpace; src: url("../data/fonts/Ahem.ttf"); unicode-range: U+0020, U+0041-005A; }
+ @font-face { font-family: FiraCode; src: url("../../Assets/FiraCode-Latin.woff2"); }
+ body { margin: 0; }
+ div { width: 200px; font: 20px/30px CapitalsAndSpace, FiraCode; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
+</style>
+<div>ABCDEFGHIJKLMNOPQRST</div>