[librsvg: 3/7] TextOrientation - define the text-orientation property




commit e57fa6f1199175cd7f94e17456b6cb68be2627d8
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Oct 26 11:23:37 2021 -0500

    TextOrientation - define the text-orientation property
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/622>

 src/property_defs.rs | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/src/property_defs.rs b/src/property_defs.rs
index 76f9924c4..2ce83dbf5 100644
--- a/src/property_defs.rs
+++ b/src/property_defs.rs
@@ -43,7 +43,9 @@ use language_tags::LanguageTag;
 use crate::dasharray::Dasharray;
 use crate::error::*;
 use crate::filter::FilterValueList;
-use crate::font_props::{Font, FontFamily, FontSize, FontWeight, LetterSpacing, LineHeight};
+use crate::font_props::{
+    Font, FontFamily, FontSize, FontWeight, GlyphOrientationVertical, LetterSpacing, LineHeight,
+};
 use crate::iri::Iri;
 use crate::length::*;
 use crate::paint_server::PaintServer;
@@ -986,6 +988,33 @@ fn parses_text_decoration() {
     assert!(TextDecoration::parse_str("airline").is_err())
 }
 
+make_property!(
+    /// `text-orientation` property.
+    ///
+    /// https://www.w3.org/TR/css-writing-modes-3/#propdef-text-orientation
+    TextOrientation,
+    default: Mixed,
+    inherits_automatically: true,
+
+    identifiers:
+    "mixed" => Mixed,
+    "upright" => Upright,
+    "sideways" => Sideways,
+);
+
+impl From<GlyphOrientationVertical> for TextOrientation {
+    /// Converts the `glyph-orientation-vertical` shorthand to a `text-orientation` longhand.
+    ///
+    /// See https://www.w3.org/TR/css-writing-modes-3/#propdef-glyph-orientation-vertical for the conversion 
table.
+    fn from(o: GlyphOrientationVertical) -> TextOrientation {
+        match o {
+            GlyphOrientationVertical::Auto => TextOrientation::Mixed,
+            GlyphOrientationVertical::Angle0 => TextOrientation::Upright,
+            GlyphOrientationVertical::Angle90 => TextOrientation::Sideways,
+        }
+    }
+}
+
 make_property!(
     /// `text-rendering` property.
     ///


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