[librsvg: 2/3] (#804) - tspan that changes the text direction is placed incorrectly




commit f412f2b749e38623f04af2eb05f7b91d90a82f6d
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Oct 19 13:29:39 2021 -0500

    (#804) - tspan that changes the text direction is placed incorrectly
    
    The code was using the direction from the span, not the direction of
    its parent chunk, and it is the chunk's direction that lays out its
    child spans.
    
    I don't think this will handle nested <tspan> that change directions,
    but that's for later.
    
    Fixes https://gitlab.gnome.org/GNOME/librsvg/-/issues/804
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/615>

 src/text.rs                                             |   4 ++--
 .../reftests/bugs/804-tspan-direction-change-ref.png    | Bin 0 -> 2574 bytes
 .../reftests/bugs/804-tspan-direction-change.svg        |  16 ++++++++++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/text.rs b/src/text.rs
index 3d890e4e..c2159d47 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -180,12 +180,12 @@ impl PositionedChunk {
             let dx = mspan.dx;
             let dy = mspan.dy;
 
-            let start_pos = match values.direction() {
+            let start_pos = match measured.values.direction() {
                 Direction::Ltr => (x, y),
                 Direction::Rtl => (x - mspan.advance.0, y),
             };
 
-            let span_advance = match values.direction() {
+            let span_advance = match measured.values.direction() {
                 Direction::Ltr => (mspan.advance.0, mspan.advance.1),
                 Direction::Rtl => (-mspan.advance.0, mspan.advance.1),
             };
diff --git a/tests/fixtures/reftests/bugs/804-tspan-direction-change-ref.png 
b/tests/fixtures/reftests/bugs/804-tspan-direction-change-ref.png
new file mode 100644
index 00000000..fedfee41
Binary files /dev/null and b/tests/fixtures/reftests/bugs/804-tspan-direction-change-ref.png differ
diff --git a/tests/fixtures/reftests/bugs/804-tspan-direction-change.svg 
b/tests/fixtures/reftests/bugs/804-tspan-direction-change.svg
new file mode 100644
index 00000000..75266985
--- /dev/null
+++ b/tests/fixtures/reftests/bugs/804-tspan-direction-change.svg
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg xmlns="http://www.w3.org/2000/svg";
+     width="100%" height="100%" viewBox="0 0 600 72"
+     direction="rtl" xml:lang="he">
+
+  <title direction="ltr" xml:lang="en">Right-to-left Text</title>
+  <desc direction="ltr" xml:lang="en">
+    An example for using the 'direction' and 'unicode-bidi' properties
+    in documents that predominantly use right-to-left languages.
+  </desc>
+
+  <text x="300" y="50" text-anchor="middle" font-size="20"> כתובת MAC:&#x200F;
+    <tspan direction="ltr" unicode-bidi="embed">00-24-AF-2A-55-FC</tspan> 
+  </text>
+
+</svg>


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