Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ImportedProjects
SVG
Commits
131eb6bc
Commit
131eb6bc
authored
May 31, 2015
by
Tebjan Halm
Browse files
Merge pull request #146 from JoshMcCullough/#145
Fixed #145 - SVG incorrectly renders <title> elements.
parents
6104ff9e
84c22eb1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Source/Document Structure/SvgDescription.cs
View file @
131eb6bc
...
@@ -7,7 +7,7 @@ namespace Svg
...
@@ -7,7 +7,7 @@ namespace Svg
{
{
[
DefaultProperty
(
"Text"
)]
[
DefaultProperty
(
"Text"
)]
[
SvgElement
(
"desc"
)]
[
SvgElement
(
"desc"
)]
public
class
SvgDescription
:
SvgElement
public
class
SvgDescription
:
SvgElement
,
ISvgDescriptiveElement
{
{
public
override
string
ToString
()
public
override
string
ToString
()
{
{
...
...
Source/Document Structure/SvgTitle.cs
View file @
131eb6bc
...
@@ -6,7 +6,7 @@ using System.ComponentModel;
...
@@ -6,7 +6,7 @@ using System.ComponentModel;
namespace
Svg
namespace
Svg
{
{
[
SvgElement
(
"title"
)]
[
SvgElement
(
"title"
)]
public
class
SvgTitle
:
SvgElement
public
class
SvgTitle
:
SvgElement
,
ISvgDescriptiveElement
{
{
public
override
string
ToString
()
public
override
string
ToString
()
{
{
...
...
Source/SvgElement.cs
View file @
131eb6bc
...
@@ -1198,6 +1198,10 @@ namespace Svg
...
@@ -1198,6 +1198,10 @@ namespace Svg
string
Content
{
get
;
}
string
Content
{
get
;
}
}
}
/// <summary>This interface mostly indicates that a node is not to be drawn when rendering the SVG.</summary>
public
interface
ISvgDescriptiveElement
{
}
internal
interface
ISvgElement
internal
interface
ISvgElement
{
{
SvgElement
Parent
{
get
;}
SvgElement
Parent
{
get
;}
...
...
Source/Text/SvgTextBase.cs
View file @
131eb6bc
...
@@ -276,7 +276,7 @@ namespace Svg
...
@@ -276,7 +276,7 @@ namespace Svg
internal
virtual
IEnumerable
<
ISvgNode
>
GetContentNodes
()
internal
virtual
IEnumerable
<
ISvgNode
>
GetContentNodes
()
{
{
return
(
this
.
Nodes
==
null
||
this
.
Nodes
.
Count
<
1
?
this
.
Children
.
OfType
<
ISvgNode
>()
:
this
.
Nodes
);
return
(
this
.
Nodes
==
null
||
this
.
Nodes
.
Count
<
1
?
this
.
Children
.
OfType
<
ISvgNode
>()
.
Where
(
o
=>
!(
o
is
ISvgDescriptiveElement
))
:
this
.
Nodes
);
}
}
protected
virtual
GraphicsPath
GetBaselinePath
(
ISvgRenderer
renderer
)
protected
virtual
GraphicsPath
GetBaselinePath
(
ISvgRenderer
renderer
)
{
{
...
@@ -319,10 +319,9 @@ namespace Svg
...
@@ -319,10 +319,9 @@ namespace Svg
/// <param name="state">State of the drawing operation</param>
/// <param name="state">State of the drawing operation</param>
private
void
SetPath
(
TextDrawingState
state
,
bool
doMeasurements
)
private
void
SetPath
(
TextDrawingState
state
,
bool
doMeasurements
)
{
{
SvgTextBase
inner
;
TextDrawingState
newState
;
TextDrawingState
origState
=
null
;
TextDrawingState
origState
=
null
;
bool
alignOnBaseline
=
state
.
BaselinePath
!=
null
&&
(
this
.
TextAnchor
==
SvgTextAnchor
.
Middle
||
this
.
TextAnchor
==
SvgTextAnchor
.
End
);
bool
alignOnBaseline
=
state
.
BaselinePath
!=
null
&&
(
this
.
TextAnchor
==
SvgTextAnchor
.
Middle
||
this
.
TextAnchor
==
SvgTextAnchor
.
End
);
if
(
doMeasurements
)
if
(
doMeasurements
)
{
{
if
(
this
.
TextLength
!=
SvgUnit
.
None
)
if
(
this
.
TextLength
!=
SvgUnit
.
None
)
...
@@ -338,15 +337,17 @@ namespace Svg
...
@@ -338,15 +337,17 @@ namespace Svg
foreach
(
var
node
in
GetContentNodes
())
foreach
(
var
node
in
GetContentNodes
())
{
{
inner
=
node
as
SvgTextBase
;
SvgTextBase
textNode
=
node
as
SvgTextBase
;
if
(
inner
==
null
)
if
(
textNode
==
null
)
{
{
if
(!
string
.
IsNullOrEmpty
(
node
.
Content
))
state
.
DrawString
(
PrepareText
(
node
.
Content
));
if
(!
string
.
IsNullOrEmpty
(
node
.
Content
))
state
.
DrawString
(
PrepareText
(
node
.
Content
));
}
}
else
else
{
{
newState
=
new
TextDrawingState
(
state
,
inner
);
TextDrawingState
newState
=
new
TextDrawingState
(
state
,
textNode
);
inner
.
SetPath
(
newState
);
textNode
.
SetPath
(
newState
);
state
.
NumChars
+=
newState
.
NumChars
;
state
.
NumChars
+=
newState
.
NumChars
;
state
.
Current
=
newState
.
Current
;
state
.
Current
=
newState
.
Current
;
}
}
...
...
Source/Text/SvgTextRef.cs
View file @
131eb6bc
...
@@ -20,14 +20,20 @@ namespace Svg
...
@@ -20,14 +20,20 @@ namespace Svg
internal
override
IEnumerable
<
ISvgNode
>
GetContentNodes
()
internal
override
IEnumerable
<
ISvgNode
>
GetContentNodes
()
{
{
var
refText
=
this
.
OwnerDocument
.
IdManager
.
GetElementById
(
this
.
ReferencedElement
)
as
SvgTextBase
;
var
refText
=
this
.
OwnerDocument
.
IdManager
.
GetElementById
(
this
.
ReferencedElement
)
as
SvgTextBase
;
IEnumerable
<
ISvgNode
>
contentNodes
=
null
;
if
(
refText
==
null
)
if
(
refText
==
null
)
{
{
return
base
.
GetContentNodes
();
contentNodes
=
base
.
GetContentNodes
();
}
}
else
else
{
{
return
refText
.
GetContentNodes
();
contentNodes
=
refText
.
GetContentNodes
();
}
}
contentNodes
=
contentNodes
.
Where
(
o
=>
!(
o
is
ISvgDescriptiveElement
));
return
contentNodes
;
}
}
public
override
SvgElement
DeepCopy
()
public
override
SvgElement
DeepCopy
()
...
...
Tests/W3CTestSuite/png/__title.png
0 → 100644
View file @
131eb6bc
1.25 KB
Tests/W3CTestSuite/svg/__title.svg
0 → 100644
View file @
131eb6bc
<svg
version=
"1.1"
style=
"font-family:Arial;font-size:12px;font-weight:normal;"
xmlns=
"http://www.w3.org/2000/svg"
width=
"600"
height=
"200"
>
<text
x=
"200"
y=
"100"
text-anchor=
"end"
style=
"color:red;font-size:12px;fill:red;"
>
<tspan>
This is visible text.
</tspan>
<title>
THIS SHOULD NOT BE SEEN! THIS SHOULD NOT BE SEEN!
</title>
</text>
</svg>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment