[librsvg: 16/22] text_anchor_advance: take a horizontal flag, not the whole WritingMode




commit 1f4d0729ee9b2beb661298b57f1c824d036dab3c
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Sep 23 11:19:06 2021 -0500

    text_anchor_advance: take a horizontal flag, not the whole WritingMode
    
    This is the "horizontal" flag from laying out the whole <text>
    element, per the text layout algorithm in the SVG2 spec.  I'm starting
    to question it, though - what if there is embedding of vertical within
    horizontal text?  Shouldn't it be per-chunk or per-span as usual?
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/593>

 src/text.rs | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/src/text.rs b/src/text.rs
index c786f17a..f55a6a0f 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -114,7 +114,7 @@ impl PositionedChunk {
     fn from_measured(
         measured: &MeasuredChunk,
         view_params: &ViewParams,
-        _text_is_horizontal: bool,
+        text_is_horizontal: bool,
         x: f64,
         y: f64,
     ) -> PositionedChunk {
@@ -124,7 +124,7 @@ impl PositionedChunk {
 
         let adjusted_advance = text_anchor_advance(
             measured.values.text_anchor(),
-            measured.values.writing_mode(),
+            text_is_horizontal,
             measured.advance,
         );
 
@@ -174,10 +174,10 @@ impl PositionedChunk {
 
 fn text_anchor_advance(
     anchor: TextAnchor,
-    writing_mode: WritingMode,
+    text_is_horizontal: bool,
     advance: (f64, f64),
 ) -> (f64, f64) {
-    if writing_mode.is_horizontal() {
+    if text_is_horizontal {
         match anchor {
             TextAnchor::Start => (0.0, 0.0),
             TextAnchor::Middle => (-advance.0 / 2.0, 0.0),
@@ -906,17 +906,17 @@ mod tests {
     #[test]
     fn adjusted_advance_horizontal() {
         assert_eq!(
-            text_anchor_advance(TextAnchor::Start, WritingMode::LrTb, (2.0, 4.0)),
+            text_anchor_advance(TextAnchor::Start, true, (2.0, 4.0)),
             (0.0, 0.0)
         );
 
         assert_eq!(
-            text_anchor_advance(TextAnchor::Middle, WritingMode::LrTb, (2.0, 4.0)),
+            text_anchor_advance(TextAnchor::Middle, true, (2.0, 4.0)),
             (-1.0, 0.0)
         );
 
         assert_eq!(
-            text_anchor_advance(TextAnchor::End, WritingMode::LrTb, (2.0, 4.0)),
+            text_anchor_advance(TextAnchor::End, true, (2.0, 4.0)),
             (-2.0, 0.0)
         );
     }
@@ -928,17 +928,17 @@ mod tests {
     #[test]
     fn adjusted_advance_vertical() {
         assert_eq!(
-            text_anchor_advance(TextAnchor::Start, WritingMode::Tb, (2.0, 4.0)),
+            text_anchor_advance(TextAnchor::Start, false, (2.0, 4.0)),
             (0.0, 0.0)
         );
 
         assert_eq!(
-            text_anchor_advance(TextAnchor::Middle, WritingMode::Tb, (2.0, 4.0)),
+            text_anchor_advance(TextAnchor::Middle, false, (2.0, 4.0)),
             (0.0, -2.0)
         );
 
         assert_eq!(
-            text_anchor_advance(TextAnchor::End, WritingMode::Tb, (2.0, 4.0)),
+            text_anchor_advance(TextAnchor::End, false, (2.0, 4.0)),
             (0.0, -4.0)
         );
     }


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