From 1094d80b10379d369246acc9d8df555992dc2548 Mon Sep 17 00:00:00 2001 From: mpalmans Date: Sun, 2 Apr 2017 18:30:24 +0200 Subject: [PATCH] SVG: Added support for curves and removed flattening of the geometry --- src/WpfMath/CharBox.cs | 3 +- src/WpfMath/SVGConverter.cs | 96 +++++++++++++++++++++++++++++++++---- 2 files changed, 89 insertions(+), 10 deletions(-) diff --git a/src/WpfMath/CharBox.cs b/src/WpfMath/CharBox.cs index b1fc8606..26fe55f3 100644 --- a/src/WpfMath/CharBox.cs +++ b/src/WpfMath/CharBox.cs @@ -46,8 +46,7 @@ public override void RenderGeometry(GeometryGroup geometry, double scale, double GlyphRun glyphRun = GetGlyphRun(scale, x, y); GeometryGroup geoGroup = glyphRun.BuildGeometry() as GeometryGroup; - PathGeometry pg = geoGroup.GetFlattenedPathGeometry(); - geometry.Children.Add(pg); + geometry.Children.Add(geoGroup); } public override int GetLastFontId() diff --git a/src/WpfMath/SVGConverter.cs b/src/WpfMath/SVGConverter.cs index 922a6af5..7918d191 100644 --- a/src/WpfMath/SVGConverter.cs +++ b/src/WpfMath/SVGConverter.cs @@ -4,6 +4,7 @@ using System.Text; using System.Windows.Media; using System.Globalization; +using System.Diagnostics; namespace WpfMath { @@ -48,6 +49,10 @@ private void AddGeometry(StringBuilder svgString, GeometryGroup group) RectangleGeometry rectangle = (RectangleGeometry)geometry; AddGeometry(svgString, rectangle); } + else + { + Debug.Assert(false); + } } if (!group.Transform.Value.IsIdentity) { @@ -61,22 +66,97 @@ private void AddGeometry(StringBuilder svgString, GeometryGroup group) private void AddGeometry(StringBuilder svgString, PathGeometry path) { svgString.Append(""); svgString.Append(Environment.NewLine);