SvgTextSpan.cs 3.61 KB
Newer Older
davescriven's avatar
davescriven committed
1
2
3
using System;
using System.ComponentModel;
using System.Collections.Generic;
4
using System.Drawing.Drawing2D;
davescriven's avatar
davescriven committed
5
6
using System.Linq;
using System.Text;
7
using Svg.DataTypes;
davescriven's avatar
davescriven committed
8
9
10

namespace Svg
{
11
    [SvgElement("tspan")]
12
	public class SvgTextSpan : SvgElement
davescriven's avatar
davescriven committed
13
    {
14
15
16
17
		private SvgUnit _x;
		private SvgUnit _y;
		private SvgUnit _dx;
		private SvgUnit _dy;
18
        private FontData _fontData = new FontData();
19
20
21
22
23
24
25

		/// <summary>
		/// Gets or sets the X.
		/// </summary>
		/// <value>The X.</value>
		[SvgAttribute("x")]
		public SvgUnit X
davescriven's avatar
davescriven committed
26
        {
27
28
29
30
31
32
33
34
35
36
			get { return this._x; }
			set { this._x = value; }
		}

		/// <summary>
		/// Gets or sets the X.
		/// </summary>
		/// <value>The X.</value>
		[SvgAttribute("y")]
		public SvgUnit Y
davescriven's avatar
davescriven committed
37
        {
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
			get { return this._y; }
			set { this._y = value; }
		}


		/// <summary>
		/// Gets or sets the deltaX from the containing text.
		/// </summary>
		/// <value>The dX.</value>
		[SvgAttribute("dx")]
		public SvgUnit DX
		{
			get { return this._dx; }
			set { this._dx = value; }
		}

		/// <summary>
		/// Gets or sets the deltaY from the containing text.
		/// </summary>
		/// <value>The dY.</value>
		[SvgAttribute("dy")]
		public SvgUnit DY
		{
			get { return this._dy; }
			set { this._dy = value; }
		}
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

        /// <summary>
        /// Gets or sets the fill <see cref="SvgPaintServer"/> of this element.
        /// </summary>
        [SvgAttribute("fill")]
        public virtual SvgPaintServer Fill
        {
            get { return (this.Attributes["fill"] == null) ? SvgColourServer.NotSet : (SvgPaintServer)this.Attributes["fill"]; }
            set { this.Attributes["fill"] = value; }
        }

        /// <summary>
        /// Indicates which font family is to be used to render the text.
        /// </summary>
        [SvgAttribute("font-family")]
        public virtual string FontFamily
        {
            get { return this._fontData.FontFamily; }
            set { this._fontData.FontFamily = value; }
        }

        /// <summary>
        /// Refers to the size of the font from baseline to baseline when multiple lines of text are set solid in a multiline layout environment.
        /// </summary>
        [SvgAttribute("font-size")]
        public virtual SvgUnit FontSize
        {
            get { return this._fontData.FontSize; }
            set { this._fontData.FontSize = value; }
        }


        /// <summary>
        /// Refers to the boldness of the font.
        /// </summary>
        [SvgAttribute("font-weight")]
        public virtual SvgFontWeight FontWeight
        {
            get { return this._fontData.FontWeight; }
            set { this._fontData.FontWeight = value; }
        }

        /// <summary>
        /// Set all font information.
        /// </summary>
        [SvgAttribute("font")]
        public virtual string Font
        {
            get { return this._fontData.Font; }
            set { _fontData.Font = value; }
        }
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
		

		/// <summary>
		/// Gets or sets the text to be rendered.
		/// </summary>
		public virtual string Text
		{
			get { return base.Content; }
			set { base.Content = value; this.Content = value; }
		}



		public override SvgElement DeepCopy()
		{
			return DeepCopy<SvgTextSpan>();
		}

		public override SvgElement DeepCopy<T>()
		{
			var newObj = base.DeepCopy<T>() as SvgTextSpan;
			newObj.X = this.X;
			newObj.Y = this.Y;
			newObj.DX = this.DX;
			newObj.DY = this.DY;
			newObj.Text = this.Text;

			return newObj;
		}

145
        internal FontData FontInfo { get { return _fontData; } }
davescriven's avatar
davescriven committed
146
147
    }
}