[librsvg] Length: Basic tests for FontEm / FontEx normalization



commit 829bf752c6d9a1ab021f2a5f50a351da7c326612
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Sep 3 15:09:03 2018 -0500

    Length: Basic tests for FontEm / FontEx normalization

 rsvg_internals/src/length.rs | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/rsvg_internals/src/length.rs b/rsvg_internals/src/length.rs
index f3a3881a..6a461f92 100644
--- a/rsvg_internals/src/length.rs
+++ b/rsvg_internals/src/length.rs
@@ -463,6 +463,31 @@ mod tests {
         );
     }
 
+    #[test]
+    fn normalize_font_em_ex_works() {
+        let params = ViewParams {
+            dpi_x: 40.0,
+            dpi_y: 40.0,
+            view_box_width: 100.0,
+            view_box_height: 200.0,
+        };
+
+        let values = ComputedValues::default();
+
+        // These correspond to the default size for the font-size
+        // property and the way we compute FontEx from that.
+
+        assert_approx_eq_cairo!(
+            Length::new(1.0, LengthUnit::FontEm, LengthDir::Vertical).normalize(&values, &params),
+            12.0
+        );
+
+        assert_approx_eq_cairo!(
+            Length::new(1.0, LengthUnit::FontEx, LengthDir::Vertical).normalize(&values, &params),
+            6.0
+        );
+    }
+
     fn parse_dash_array_str(s: &str) -> Result<Dasharray, AttributeError> {
         Dasharray::parse_str(s, ())
     }


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