[librsvg: 18/20] Test for when a span has a dx larger than its size




commit 6a5abe51fe4ec656f18c83309b8807d43ba1bf56
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Oct 20 14:40:01 2021 -0500

    Test for when a span has a dx larger than its size
    
    This is a minimal test for the bug that happens in
    https://upload.wikimedia.org/wikipedia/commons/f/f7/S-Bahn_RheinNeckar2020.svg
    where it says
    
       Freinsheim/
        Grünstadt/
      Bad Dürkheim
                 ^
                 |
           aligned here
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/616>

 tests/fixtures/text/span-bounds-when-offset-by-dx-ref.svg | 9 +++++++++
 tests/fixtures/text/span-bounds-when-offset-by-dx.svg     | 9 +++++++++
 tests/src/text.rs                                         | 6 ++++++
 3 files changed, 24 insertions(+)
---
diff --git a/tests/fixtures/text/span-bounds-when-offset-by-dx-ref.svg 
b/tests/fixtures/text/span-bounds-when-offset-by-dx-ref.svg
new file mode 100644
index 00000000..2ba29dd7
--- /dev/null
+++ b/tests/fixtures/text/span-bounds-when-offset-by-dx-ref.svg
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"; width="600" height="300">
+  <rect x="0" y="0" width="100%" height="100%" fill="white"/>
+  <line x1="50%" y1="0" x2="50%" y2="100%" stroke-width="2" stroke="blue"/>
+  <line x1="0" y1="100" x2="100%" y2="100" stroke-width="2" stroke="blue"/>
+
+  <rect x="280" y="64" width="20" height="20" fill="black"/>
+  <rect x="260" y="84" width="40" height="20" fill="black"/>
+</svg>
diff --git a/tests/fixtures/text/span-bounds-when-offset-by-dx.svg 
b/tests/fixtures/text/span-bounds-when-offset-by-dx.svg
new file mode 100644
index 00000000..9abd6bc7
--- /dev/null
+++ b/tests/fixtures/text/span-bounds-when-offset-by-dx.svg
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"; width="600" height="300">
+  <rect x="0" y="0" width="100%" height="100%" fill="white"/>
+  <line x1="50%" y1="0" x2="50%" y2="100%" stroke-width="2" stroke="blue"/>
+  <line x1="0" y1="100" x2="100%" y2="100" stroke-width="2" stroke="blue"/>
+
+  <!-- If the dx on the second span is larger than the width of the first span... -->
+  <text x="50%" y="100" font-family="Ahem" font-size="20" text-anchor="end"><tspan dy="-1em">A</tspan><tspan 
dx="-40" dy="1em">BC</tspan></text>
+</svg>
diff --git a/tests/src/text.rs b/tests/src/text.rs
index 605c9275..cc3c1527 100644
--- a/tests/src/text.rs
+++ b/tests/src/text.rs
@@ -33,3 +33,9 @@ test_svg_reference!(
     "tests/fixtures/text/806-text-anchor-chunk.svg",
     "tests/fixtures/text/806-text-anchor-chunk-ref.svg"
 );
+
+test_svg_reference!(
+    span_bounds_when_offset_by_dx,
+    "tests/fixtures/text/span-bounds-when-offset-by-dx.svg",
+    "tests/fixtures/text/span-bounds-when-offset-by-dx-ref.svg"
+);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]