Skip to content

Commit

Permalink
Bug Fixes Prior to Work on Better CSS Support
Browse files Browse the repository at this point in the history
  • Loading branch information
erdomke committed Jul 31, 2014
1 parent ce8f2a6 commit 32ea4ec
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Source/Basic Shapes/SvgVisualElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions Source/Painting/SvgDeferredPaintServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static T TryGet<T>(SvgPaintServer server) where T : SvgPaintServer
}
else
{
deferred.EnsureServer();
return deferred._concreteServer as T;
}
}
Expand Down
1 change: 1 addition & 0 deletions Source/Text/SvgTextAnchor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Svg
[TypeConverter(typeof(SvgTextAnchorConverter))]
public enum SvgTextAnchor
{
inherit,
/// <summary>
/// The rendered characters are aligned such that the start of the text string is at the initial current text position.
/// </summary>
Expand Down
16 changes: 13 additions & 3 deletions Source/Text/SvgTextBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -196,7 +196,15 @@ protected override bool RequiresSmoothRendering
/// <value>The bounds.</value>
public override System.Drawing.RectangleF Bounds
{
get { return this.Path.GetBounds(); }
get
{
var path = this.Path;
foreach (var elem in this.Children.OfType<SvgVisualElement>())
{
path.AddPath(elem.Path, false);
}
return path.GetBounds();
}
}

private static string ValidateFontFamily(string fontFamilyList)
Expand Down Expand Up @@ -361,8 +369,10 @@ public override System.Drawing.Drawing2D.GraphicsPath Path
_path = new GraphicsPath();
_path.StartFigure();

var anchorElem = (from e in this.ParentsAndSelf.OfType<SvgTextBase>() 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);
Expand Down

0 comments on commit 32ea4ec

Please sign in to comment.