private void FlushPath()
{
if (_currPath != null)
{
_currPath.CloseFigure();
// Abort on empty paths (e.g. rendering a space)
if (_currPath.PointCount < 1)
{
_anchoredPaths.Clear();
_xAnchor = float.MinValue;
_currPath = null;
return;
}
if (_xAnchor > float.MinValue)
{
float minX = float.MaxValue;
float maxX = float.MinValue;
RectangleF bounds;
foreach (var path in _anchoredPaths)
{
bounds = path.GetBounds();
if (bounds.Left < minX) minX = bounds.Left;
if (bounds.Right > maxX) maxX = bounds.Right;
}
var xOffset = 0f; //_xAnchor - minX;
switch (Element.TextAnchor)
{
case SvgTextAnchor.Middle:
xOffset -= (maxX - minX) / 2;
break;
case SvgTextAnchor.End:
xOffset -= (maxX - minX);
break;
}
if (xOffset != 0)
{
using (var matrix = new Matrix())
{
matrix.Translate(xOffset, 0);
foreach (var path in _anchoredPaths)
{
path.Transform(matrix);
}
}
}
_anchoredPaths.Clear();
_xAnchor = float.MinValue;
}
if (_finalPath == null)
{
_finalPath = _currPath;
}
else
{
_finalPath.AddPath(_currPath, false);
}
_currPath = null;
}
}