[librsvg: 5/20] Extract function to compute the baseline offset for a span




commit d30ce4e8f013b918c2e07ec122027ca09f61fbb9
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Oct 19 18:37:29 2021 -0500

    Extract function to compute the baseline offset for a span
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/616>

 src/text.rs | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/text.rs b/src/text.rs
index cf0c2f5e..c38a68da 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -171,9 +171,7 @@ impl PositionedChunk {
             let layout = mspan.layout.clone();
             let values = mspan.values.clone();
 
-            let baseline = f64::from(layout.baseline()) / f64::from(pango::SCALE);
-            let baseline_shift = values.baseline_shift().0.to_user(&params);
-            let baseline_offset = baseline + baseline_shift;
+            let baseline_offset = compute_baseline_offset(&layout, &values, &params);
 
             let dx = mspan.dx;
             let dy = mspan.dy;
@@ -215,6 +213,16 @@ impl PositionedChunk {
     }
 }
 
+fn compute_baseline_offset(
+    layout: &pango::Layout,
+    values: &ComputedValues,
+    params: &NormalizeParams,
+) -> f64 {
+    let baseline = f64::from(layout.baseline()) / f64::from(pango::SCALE);
+    let baseline_shift = values.baseline_shift().0.to_user(&params);
+    baseline + baseline_shift
+}
+
 /// Computes the (x, y) offsets to be applied to spans after applying the text-anchor property (start, 
middle, end).
 #[rustfmt::skip]
 fn text_anchor_offset(


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