SVG
SVG copied to clipboard
Adding "paint-order" attribute support paint order
Hello I using this library but it's dont have paint order functionalty. it's necessary for the nicely stroked Text ( most of handwriting font etc.)
I made two little change on code solve this problem. and it's working nice.
https://github.com/vvvv/SVG/blob/691dfd6e9327e7276a7c057e330d0f418c06e282/Source/Basic%20Shapes/SvgVisualElement.cs#L213-L225
Replace this method with:
protected internal virtual void RenderFillAndStroke(ISvgRenderer renderer)
{
// If this element needs smoothing enabled turn anti-aliasing on
if (RequiresSmoothRendering)
renderer.SmoothingMode = SmoothingMode.AntiAlias;
if (this.PaintOrder=="fill")
{
RenderFill(renderer);
RenderStroke(renderer);
}
else
{
RenderStroke(renderer);
RenderFill(renderer);
}
// Reset the smoothing mode
if (RequiresSmoothRendering && renderer.SmoothingMode == SmoothingMode.AntiAlias)
renderer.SmoothingMode = SmoothingMode.Default;
}
And add this attribute defination to Source/SvgElementStyle.cs
/// <summary>
/// Specifies paint order of the stroke and fill when rendering the object.
/// this attribute can be "fill" or "stroke"
/// </summary>
[SvgAttribute("paint-order")]
public virtual string PaintOrder
{
get { return GetAttribute("paint-order", false, "fill"); }
set { Attributes["paint-order"] = value; IsPathDirty = true; }
}
After this changes use can use it with:
SvgDocument mdoc = SvgDocument.Open("C:\\myfile.svg");
SvgText mtext = new SvgText("Burak");
mtext.Fill = new SvgColourServer(Color.Yellow);
mtext.Stroke = new SvgColourServer(Color.Black);
mtext.StrokeWidth = 2;
mtext.PaintOrder = "stroke"; // "stroke" or "fill"
mdoc.Children.Add(mtext);
Bitmap result = mdoc.Draw();
First Stroke:
First Fill:
paint-order
specification is here.
Any progress on getting this merged in to an upcoming release?