You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note in the first and third rectangles, the fill attribute is blue, but the style contains fill but it's empty. In a browser, this renders as a blue/red/blue box stack.
In 0.5.18, it rendered the same, blue/red/blue. But in 0.5.22.1 and 1.0.0.18, it draws as black/red/black.
Sample console app:
To reproduce, put this in Program.cs:
var svgText = @"<svg width=""20"" height=""60"">
<rect width=""20"" height=""20"" fill=""rgb(0,0,255)"" stroke-width=""3"" stroke=""rgb(0,0,0)"" style=""fill:;stroke:rgb(255,255,255);""></rect>
<rect y=""20"" width=""20"" height=""20"" fill=""rgb(0,0,255)"" stroke-width=""3"" stroke=""rgb(0,0,0)"" style=""fill:rgb(244,58,32);stroke:rgb(255,255,255);""></rect>
<rect y=""40"" width=""20"" height=""20"" fill=""rgb(0,0,255)"" stroke-width=""3"" stroke=""rgb(0,0,0)"" style=""fill:;stroke:rgb(255,255,255);""></rect>
</svg>";
using var bmp = new SkiaSharp.SKBitmap(20, 60);
using var canvas = new SkiaSharp.SKCanvas(bmp);
using var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(svgText));
ms.Position = 0;
//1.0.0.18 syntax
//using var svg = Svg.Skia.SKSvg.CreateFromStream(ms);
//0.5.18 syntax
using var svg = new Svg.Skia.SKSvg();
svg.Load(ms);
canvas.DrawPicture(svg.Picture);
For 0.5.18, you get blue/red/blue. Change the nuget to 0.5.22.1 and get black/red/black. Change nuget to 1.0.0.18 and switch the svg load lines, and you get black/red/black.
If you change SvgElementFactory.SetAttributes to check if declaration.Original is null or whitespace and skip it, then it draws blue/red/blue again.
if (localName.Equals("style") && !(element is NonSvgElement))
{
var inlineSheet = stylesheetParser.Parse("#a{" + reader.Value + "}");
foreach (var rule in inlineSheet.StyleRules) {
foreach (var declaration in rule.Style) {
if (!string.IsNullOrWhiteSpace(declaration.Original)) {
element.AddStyle(declaration.Name, declaration.Original, SvgElement.StyleSpecificity_InlineStyle);
}
}
}
}
Can you think of any reason why changing this would break anything?
The text was updated successfully, but these errors were encountered:
Consider this svg:
Note in the first and third rectangles, the fill attribute is blue, but the style contains fill but it's empty. In a browser, this renders as a blue/red/blue box stack.
In 0.5.18, it rendered the same, blue/red/blue. But in 0.5.22.1 and 1.0.0.18, it draws as black/red/black.
Sample console app:
To reproduce, put this in Program.cs:
For 0.5.18, you get blue/red/blue. Change the nuget to 0.5.22.1 and get black/red/black. Change nuget to 1.0.0.18 and switch the svg load lines, and you get black/red/black.
If you change SvgElementFactory.SetAttributes to check if declaration.Original is null or whitespace and skip it, then it draws blue/red/blue again.
Can you think of any reason why changing this would break anything?
The text was updated successfully, but these errors were encountered: