diff --git a/Source/Basic Shapes/SvgVisualElement.cs b/Source/Basic Shapes/SvgVisualElement.cs index 0bebf2c74..fa84ceb96 100644 --- a/Source/Basic Shapes/SvgVisualElement.cs +++ b/Source/Basic Shapes/SvgVisualElement.cs @@ -138,7 +138,7 @@ protected internal virtual void RenderFill(SvgRenderer renderer) { if (this.Fill != null) { - using (Brush brush = this.Fill.GetBrush(this, this.FillOpacity)) + using (Brush brush = this.Fill.GetBrush(this, Math.Min(Math.Max(this.FillOpacity * this.Opacity, 0), 1))) { if (brush != null) { @@ -158,7 +158,7 @@ protected internal virtual void RenderStroke(SvgRenderer renderer) if (this.Stroke != null) { float strokeWidth = this.StrokeWidth.ToDeviceValue(this); - using (var pen = new Pen(this.Stroke.GetBrush(this, this.StrokeOpacity), strokeWidth)) + using (var pen = new Pen(this.Stroke.GetBrush(this, Math.Min(Math.Max(this.StrokeOpacity * this.Opacity, 0), 1)), strokeWidth)) { if (this.StrokeDashArray != null && this.StrokeDashArray.Count > 0) { diff --git a/Source/Painting/SvgDeferredPaintServer.cs b/Source/Painting/SvgDeferredPaintServer.cs index 88172a33b..cbd46053a 100644 --- a/Source/Painting/SvgDeferredPaintServer.cs +++ b/Source/Painting/SvgDeferredPaintServer.cs @@ -81,6 +81,7 @@ public static T TryGet(SvgPaintServer server) where T : SvgPaintServer } else { + deferred.EnsureServer(); return deferred._concreteServer as T; } } diff --git a/Source/Text/SvgTextAnchor.cs b/Source/Text/SvgTextAnchor.cs index 207bf95c9..162b22a45 100644 --- a/Source/Text/SvgTextAnchor.cs +++ b/Source/Text/SvgTextAnchor.cs @@ -12,6 +12,7 @@ namespace Svg [TypeConverter(typeof(SvgTextAnchorConverter))] public enum SvgTextAnchor { + inherit, /// /// The rendered characters are aligned such that the start of the text string is at the initial current text position. /// diff --git a/Source/Text/SvgTextBase.cs b/Source/Text/SvgTextBase.cs index c0d30c733..34a7fbe84 100644 --- a/Source/Text/SvgTextBase.cs +++ b/Source/Text/SvgTextBase.cs @@ -25,7 +25,7 @@ public abstract class SvgTextBase : SvgVisualElement private SvgUnitCollection _dx = new SvgUnitCollection(); private SvgUnit _letterSpacing; private SvgUnit _wordSpacing; - private SvgTextAnchor _textAnchor = SvgTextAnchor.Start; + private SvgTextAnchor _textAnchor = SvgTextAnchor.inherit; private static readonly SvgRenderer _stringMeasure; private const string DefaultFontFamily = "Times New Roman"; @@ -196,7 +196,15 @@ protected override bool RequiresSmoothRendering /// The bounds. public override System.Drawing.RectangleF Bounds { - get { return this.Path.GetBounds(); } + get + { + var path = this.Path; + foreach (var elem in this.Children.OfType()) + { + path.AddPath(elem.Path, false); + } + return path.GetBounds(); + } } private static string ValidateFontFamily(string fontFamilyList) @@ -361,8 +369,10 @@ public override System.Drawing.Drawing2D.GraphicsPath Path _path = new GraphicsPath(); _path.StartFigure(); + var anchorElem = (from e in this.ParentsAndSelf.OfType() where e.TextAnchor != SvgTextAnchor.inherit select e).FirstOrDefault(); + // Determine the location of the start point - switch (this.TextAnchor) + switch (anchorElem == null ? this.TextAnchor : anchorElem.TextAnchor) { case SvgTextAnchor.Middle: x -= (boundsData.Bounds.Width / 2);