Commit 1a00f391 authored by Eric Domke's avatar Eric Domke
Browse files

Bug fixes: Gradients and Filters

- Support of generic fonts (serif, sans-serif, monospace)
- Initial support of filters
- Fixes to gradient rendering
parent 2187be3e
...@@ -275,6 +275,7 @@ namespace Svg ...@@ -275,6 +275,7 @@ namespace Svg
where (n is SvgContentNode || n is SvgTextBase) && !string.IsNullOrEmpty(n.Content) where (n is SvgContentNode || n is SvgTextBase) && !string.IsNullOrEmpty(n.Content)
select n).ToList(); select n).ToList();
// Individual character spacing
if (nodes.FirstOrDefault() is SvgContentNode && _x.Count > 1) if (nodes.FirstOrDefault() is SvgContentNode && _x.Count > 1)
{ {
string ch; string ch;
...@@ -298,7 +299,9 @@ namespace Svg ...@@ -298,7 +299,9 @@ namespace Svg
} }
} }
// Calculate the bounds of the text
ISvgNode node; ISvgNode node;
var accumulateDims = true;
for (var i = 0; i < nodes.Count; i++) for (var i = 0; i < nodes.Count; i++)
{ {
node = nodes[i]; node = nodes[i];
...@@ -316,10 +319,15 @@ namespace Svg ...@@ -316,10 +319,15 @@ namespace Svg
{ {
stringBounds = innerText.GetTextBounds(renderer).Bounds; stringBounds = innerText.GetTextBounds(renderer).Bounds;
result.Nodes.Add(new NodeBounds() { Bounds = stringBounds, Node = node, xOffset = totalWidth }); result.Nodes.Add(new NodeBounds() { Bounds = stringBounds, Node = node, xOffset = totalWidth });
if (innerText.Dx.Count == 1) totalWidth += innerText.Dx[0].ToDeviceValue(renderer, UnitRenderingType.Horizontal, this); accumulateDims = accumulateDims && SvgUnitCollection.IsNullOrEmpty(innerText.X) && SvgUnitCollection.IsNullOrEmpty(innerText.Y);
if (accumulateDims && innerText.Dx.Count == 1) totalWidth += innerText.Dx[0].ToDeviceValue(renderer, UnitRenderingType.Horizontal, this);
}
if (accumulateDims)
{
totalHeight = Math.Max(totalHeight, stringBounds.Height);
totalWidth += stringBounds.Width;
} }
totalHeight = Math.Max(totalHeight, stringBounds.Height);
totalWidth += stringBounds.Width;
} }
} }
result.Bounds = new SizeF(totalWidth, totalHeight); result.Bounds = new SizeF(totalWidth, totalHeight);
......
...@@ -32,9 +32,16 @@ namespace SvgW3CTestRunner ...@@ -32,9 +32,16 @@ namespace SvgW3CTestRunner
try try
{ {
var doc = SvgDocument.Open(_svgBasePath + fileName); var doc = SvgDocument.Open(_svgBasePath + fileName);
var img = new Bitmap(480, 360); if (fileName.StartsWith("__"))
doc.Draw(img); {
picSvg.Image = img; picSvg.Image = doc.Draw();
}
else
{
var img = new Bitmap(480, 360);
doc.Draw(img);
picSvg.Image = img;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
......
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