Commit 6896260f authored by Tebjan Halm's avatar Tebjan Halm Committed by GitHub
Browse files

Merge pull request #300 from mrbean-bremen/pr/test

Fixed inheritance of  text-anchor and baseline-shift attributes
parents bb69f2be 08589350
......@@ -80,6 +80,9 @@ namespace Svg
{
var origParent = element.Parent;
element._parent = this;
// as the new parent may have other styles that are inherited,
// we have to redraw the paths for the children
element.InvalidateChildPaths();
element.RenderElement(renderer);
element._parent = origParent;
}
......
......@@ -377,9 +377,9 @@ namespace Svg
}
/// <summary>
/// Gets or sets the text anchor.
/// Gets or sets the space handling.
/// </summary>
/// <value>The text anchor.</value>
/// <value>The space handling.</value>
[SvgAttribute("space", SvgAttributeAttribute.XmlNamespace)]
public virtual XmlSpaceHandling SpaceHandling
{
......
......@@ -26,6 +26,18 @@ namespace Svg
set { this._dirty = value; }
}
/// <summary>
/// Force recreation of the paths for the element and it's children.
/// </summary>
public void InvalidateChildPaths()
{
this.IsPathDirty = true;
foreach (SvgElement element in this.Children)
{
element.InvalidateChildPaths();
}
}
protected static float FixOpacityValue(float value)
{
const float max = 1.0f;
......@@ -157,6 +169,26 @@ namespace Svg
set { this.Attributes["shape-rendering"] = value; }
}
/// <summary>
/// Gets or sets the text anchor.
/// </summary>
[SvgAttribute("text-anchor", true)]
public virtual SvgTextAnchor TextAnchor
{
get { return this.Attributes.GetInheritedAttribute<SvgTextAnchor>("text-anchor"); }
set { this.Attributes["text-anchor"] = value; this.IsPathDirty = true; }
}
/// <summary>
/// Specifies dominant-baseline positioning of text.
/// </summary>
[SvgAttribute("baseline-shift", true)]
public virtual string BaselineShift
{
get { return this.Attributes.GetInheritedAttribute<string>("baseline-shift"); }
set { this.Attributes["baseline-shift"] = value; this.IsPathDirty = true; }
}
/// <summary>
/// Indicates which font family is to be used to render the text.
/// </summary>
......
......@@ -38,24 +38,6 @@ namespace Svg
}
}
/// <summary>
/// Gets or sets the text anchor.
/// </summary>
/// <value>The text anchor.</value>
[SvgAttribute("text-anchor", true)]
public virtual SvgTextAnchor TextAnchor
{
get { return (this.Attributes["text-anchor"] == null) ? SvgTextAnchor.Inherit : (SvgTextAnchor)this.Attributes["text-anchor"]; }
set { this.Attributes["text-anchor"] = value; this.IsPathDirty = true; }
}
[SvgAttribute("baseline-shift", true)]
public virtual string BaselineShift
{
get { return this.Attributes["baseline-shift"] as string; }
set { this.Attributes["baseline-shift"] = value; this.IsPathDirty = true; }
}
public override XmlSpaceHandling SpaceHandling
{
get { return base.SpaceHandling; }
......
......@@ -163,11 +163,13 @@ text-text-08-b.svg
text-text-09-t.svg
text-text-10-t.svg
text-text-11-t.svg
text-text-12-t.svg
text-tref-01-b.svg
text-tspan-01-b.svg
text-ws-01-t.svg
text-ws-02-t.svg
text-ws-03-t.svg
types-basic-01-f.svg
painting-stroke-02-t.svg
coords-viewattr-04-f.svg
fonts-desc-01-t.svg
......
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1235" height="650" viewBox="0 0 7410 3900">
<rect width="7410" height="3900" fill="#b22234"/>
<path d="M0,450H7410m0,600H0m0,600H7410m0,600H0m0,600H7410m0,600H0" stroke="#fff" stroke-width="300"/>
<rect width="2964" height="2100" fill="#3c3b6e"/>
<g fill="#fff">
<g id="s18">
<g id="s9">
<g id="s5">
<g id="s4">
<path id="s" d="M247,90 317.534230,307.082039 132.873218,172.917961H361.126782L176.465770,307.082039z"/>
<use xlink:href="#s" y="420"/>
<use xlink:href="#s" y="840"/>
<use xlink:href="#s" y="1260"/>
</g>
<use xlink:href="#s" y="1680"/>
</g>
<use xlink:href="#s4" x="247" y="210"/>
</g>
<use xlink:href="#s9" x="494"/>
</g>
<use xlink:href="#s18" x="988"/>
<use xlink:href="#s9" x="1976"/>
<use xlink:href="#s5" x="2470"/>
</g>
</svg>
\ No newline at end of file
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