[librsvg] (#494): Fix combination of "x" and "dy" attributes for tspan elements



commit ccb0717f430cfad933683ed02685e8b3c9786339
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Aug 13 14:08:37 2019 -0500

    (#494): Fix combination of "x" and "dy" attributes for tspan elements
    
    When computing the positions of spans, the values of the dx/dy
    attributes need to be added in, not just for the render position of
    each span, but for the position of the *next* span as well.
    
    Fixes https://gitlab.gnome.org/GNOME/librsvg/issues/494

 rsvg_internals/src/text.rs                               |  12 +++++++++---
 .../reftests/bugs/494-text-accumulate-dy-ref.png         | Bin 0 -> 2800 bytes
 tests/fixtures/reftests/bugs/494-text-accumulate-dy.svg  |  14 ++++++++++++++
 3 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index 99add4f1..6e52e3c5 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -86,6 +86,8 @@ struct PositionedSpan {
     values: ComputedValues,
     _position: (f64, f64),
     rendered_position: (f64, f64),
+    next_span_x: f64,
+    next_span_y: f64,
 }
 
 impl Chunk {
@@ -148,10 +150,12 @@ impl PositionedChunk {
         // Position each span
 
         for measured_span in &measured.spans {
-            positioned.push(PositionedSpan::from_measured(measured_span, draw_ctx, x, y));
+            let positioned_span = PositionedSpan::from_measured(measured_span, draw_ctx, x, y);
 
-            x += measured_span.advance.0;
-            y += measured_span.advance.1;
+            x = positioned_span.next_span_x;
+            y = positioned_span.next_span_y;
+
+            positioned.push(positioned_span);
         }
 
         PositionedChunk {
@@ -263,6 +267,8 @@ impl PositionedSpan {
             values,
             _position: (x, y),
             rendered_position: (render_x, render_y),
+            next_span_x: x + measured.advance.0 + dx,
+            next_span_y: y + measured.advance.1 + dy,
         }
     }
 
diff --git a/tests/fixtures/reftests/bugs/494-text-accumulate-dy-ref.png 
b/tests/fixtures/reftests/bugs/494-text-accumulate-dy-ref.png
new file mode 100644
index 00000000..5b4b5299
Binary files /dev/null and b/tests/fixtures/reftests/bugs/494-text-accumulate-dy-ref.png differ
diff --git a/tests/fixtures/reftests/bugs/494-text-accumulate-dy.svg 
b/tests/fixtures/reftests/bugs/494-text-accumulate-dy.svg
new file mode 100644
index 00000000..e43808a7
--- /dev/null
+++ b/tests/fixtures/reftests/bugs/494-text-accumulate-dy.svg
@@ -0,0 +1,14 @@
+<?xml version="1.0" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg"; xml:lang="en"  viewBox="0 0 178 178" version="1.1">
+<style type="text/css">
+    svg {
+        font-family: Times;
+        font-size: 44px;
+    }
+  </style>
+  <text  x="0" y="0">
+  <tspan x="0" dy="1.2em">Tata</tspan>
+  <tspan x="0" dy="1.2em">Toto tu</tspan>
+  <tspan x="0" dy="1.2em">ppo</tspan>
+  </text>
+</svg>


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