[librsvg: 9/22] Let the positioning function know whether the whole text block has a horizontal writing mode




commit ceb0c1a918b68fc08f2e00600d5fc557ecf0d141
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Sep 23 10:43:55 2021 -0500

    Let the positioning function know whether the whole text block has a horizontal writing mode
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/593>

 src/property_defs.rs |  4 ++++
 src/text.rs          | 12 ++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/property_defs.rs b/src/property_defs.rs
index c12653be..be1524fc 100644
--- a/src/property_defs.rs
+++ b/src/property_defs.rs
@@ -1052,6 +1052,10 @@ impl WritingMode {
     pub fn is_vertical(self) -> bool {
         matches!(self, WritingMode::Tb | WritingMode::TbRl)
     }
+
+    pub fn is_horizontal(self) -> bool {
+        !self.is_vertical()
+    }
 }
 
 make_property!(
diff --git a/src/text.rs b/src/text.rs
index 8f1bc4dd..c8a35d51 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -117,6 +117,7 @@ impl PositionedChunk {
     fn from_measured(
         measured: &MeasuredChunk,
         view_params: &ViewParams,
+        _text_is_horizontal: bool,
         x: f64,
         y: f64,
     ) -> PositionedChunk {
@@ -534,6 +535,8 @@ impl Draw for Text {
 
         let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
 
+        let text_is_horizontal = values.writing_mode().is_horizontal();
+
         draw_ctx.with_discrete_layer(
             &stacking_ctx,
             acquired_nodes,
@@ -556,8 +559,13 @@ impl Draw for Text {
                     let chunk_x = chunk.x.unwrap_or(x);
                     let chunk_y = chunk.y.unwrap_or(y);
 
-                    let positioned =
-                        PositionedChunk::from_measured(chunk, &view_params, chunk_x, chunk_y);
+                    let positioned = PositionedChunk::from_measured(
+                        chunk,
+                        &view_params,
+                        text_is_horizontal,
+                        chunk_x,
+                        chunk_y,
+                    );
 
                     x = positioned.next_chunk_x;
                     y = positioned.next_chunk_y;


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