[librsvg] (#337) - Don't panic with "ex" or "em" units in the font-size property



commit 1e4c6cd57b3ae0bc208cbd48bd523c63403fbd05
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Sep 18 17:17:36 2018 -0500

    (#337) - Don't panic with "ex" or "em" units in the font-size property
    
    https://gitlab.gnome.org/GNOME/librsvg/issues/337

 rsvg_internals/src/length.rs                | 7 ++++++-
 tests/fixtures/render-crash/337-font-ex.svg | 9 +++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/rsvg_internals/src/length.rs b/rsvg_internals/src/length.rs
index ea35178a..1b89a59c 100644
--- a/rsvg_internals/src/length.rs
+++ b/rsvg_internals/src/length.rs
@@ -243,9 +243,14 @@ fn font_size_from_values(values: &ComputedValues, params: &ViewParams) -> f64 {
 
         LengthUnit::Inch => font_size_from_inch(v.length, v.dir, params),
 
-        LengthUnit::Percent | LengthUnit::FontEm | LengthUnit::FontEx => {
+        LengthUnit::Percent => {
             unreachable!("ComputedValues can't have a relative font size")
         }
+
+        LengthUnit::FontEm | LengthUnit::FontEx => {
+            // This is the same default as used in rsvg_node_svg_get_size()
+            v.hand_normalize(0.0, 0.0, 12.0)
+        }
     }
 }
 
diff --git a/tests/fixtures/render-crash/337-font-ex.svg b/tests/fixtures/render-crash/337-font-ex.svg
new file mode 100644
index 00000000..9b517e89
--- /dev/null
+++ b/tests/fixtures/render-crash/337-font-ex.svg
@@ -0,0 +1,9 @@
+<svg>
+  <style>
+  text {
+    font-size: 0ex;
+  }
+  </style>
+
+  <text>0</text>
+</svg>


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