Commit 46e375e4 authored by Eric Domke's avatar Eric Domke
Browse files

Bug Fixes

- Fixing path parsing algorithm to deal with nuanced arc cases and
hopefully improve performance
- Attempts at better memory management
- Working toward getting symbols to render correctly
parent 7c70bd11
......@@ -45,14 +45,14 @@ namespace Svg
public IList<System.Drawing.RectangleF> MeasureCharacters(ISvgRenderer renderer, string text)
{
var result = new List<RectangleF>();
GetPath(renderer, text, result, false);
using (var path = GetPath(renderer, text, result, false)) { }
return result;
}
public System.Drawing.SizeF MeasureString(ISvgRenderer renderer, string text)
{
var result = new List<RectangleF>();
GetPath(renderer, text, result, true);
using (var path = GetPath(renderer, text, result, true)) { }
var nonEmpty = result.Where(r => r != RectangleF.Empty);
if (!nonEmpty.Any()) return SizeF.Empty;
return new SizeF(nonEmpty.Last().Right - nonEmpty.First().Left, Ascent(renderer));
......@@ -63,10 +63,12 @@ namespace Svg
var textPath = GetPath(renderer, text, null, false);
if (textPath.PointCount > 0)
{
var translate = new Matrix();
translate.Translate(location.X, location.Y);
textPath.Transform(translate);
path.AddPath(textPath, false);
using (var translate = new Matrix())
{
translate.Translate(location.X, location.Y);
textPath.Transform(translate);
path.AddPath(textPath, false);
}
}
}
......@@ -99,6 +101,7 @@ namespace Svg
scaleMatrix.Scale(_emScale, -1 * _emScale, MatrixOrder.Append);
scaleMatrix.Translate(xPos, ascent, MatrixOrder.Append);
path.Transform(scaleMatrix);
scaleMatrix.Dispose();
bounds = path.GetBounds();
if (ranges != null)
......@@ -126,5 +129,11 @@ namespace Svg
if (_glyphs == null) _glyphs = _font.Descendants().OfType<SvgGlyph>().ToDictionary(g => g.Unicode ?? g.GlyphName ?? g.ID);
if (_kerning == null) _kerning = _font.Descendants().OfType<SvgKern>().ToDictionary(k => k.Glyph1 + "|" + k.Glyph2);
}
public void Dispose()
{
_glyphs = null;
_kerning = null;
}
}
}
This diff is collapsed.
......@@ -27,7 +27,7 @@ namespace Svg.Transforms
{
get
{
System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
var matrix = new System.Drawing.Drawing2D.Matrix();
matrix.Scale(this.X, this.Y);
return matrix;
}
......
......@@ -32,6 +32,7 @@ namespace SvgW3CTestRunner
var fileName = lstFiles.SelectedItem.ToString();
try
{
Debug.Print(fileName);
var doc = SvgDocument.Open(_svgBasePath + fileName);
if (fileName.StartsWith("__"))
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment