SvgFontFace.cs 4.55 KB
Newer Older
Eric Domke's avatar
Eric Domke committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Svg
{
    [SvgElement("font-face")]
    public class SvgFontFace : SvgElement
    {
        [SvgAttribute("alphabetic")]
        public float Alphabetic
        {
            get { return (this.Attributes["alphabetic"] == null ? 0 : (float)this.Attributes["alphabetic"]); }
            set { this.Attributes["alphabetic"] = value; }
        }

        [SvgAttribute("ascent")]
        public float Ascent
        {
Eric Domke's avatar
Eric Domke committed
21
22
23
24
25
26
27
28
29
30
31
32
            get 
            { 
                if (this.Attributes["ascent"] == null) 
                {
                    var font = this.Parent as SvgFont;
                    return (font == null ? 0 : this.UnitsPerEm - font.VertOriginY);
                }
                else
                {
                    return (float)this.Attributes["ascent"];
                }
            }
Eric Domke's avatar
Eric Domke committed
33
34
35
36
37
38
39
40
41
42
43
44
45
            set { this.Attributes["ascent"] = value; }
        }

        [SvgAttribute("ascent-height")]
        public float AscentHeight
        {
            get { return (this.Attributes["ascent-height"] == null ? this.Ascent : (float)this.Attributes["ascent-height"]); }
            set { this.Attributes["ascent-height"] = value; }
        }

        [SvgAttribute("descent")]
        public float Descent
        {
Eric Domke's avatar
Eric Domke committed
46
47
48
49
50
51
52
53
54
55
56
57
            get 
            { 
                if (this.Attributes["descent"] == null) 
                {
                    var font = this.Parent as SvgFont;
                    return (font == null ? 0 : font.VertOriginY);
                }
                else 
                {
                    return (float)this.Attributes["descent"];
                }
            }
Eric Domke's avatar
Eric Domke committed
58
59
60
61
62
63
64
            set { this.Attributes["descent"] = value; }
        }

        /// <summary>
        /// Indicates which font family is to be used to render the text.
        /// </summary>
        [SvgAttribute("font-family")]
65
        public override string FontFamily
Eric Domke's avatar
Eric Domke committed
66
67
68
69
70
71
72
73
74
        {
            get { return this.Attributes["font-family"] as string; }
            set { this.Attributes["font-family"] = 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")]
75
        public override SvgUnit FontSize
Eric Domke's avatar
Eric Domke committed
76
77
78
79
80
81
82
83
84
        {
            get { return (this.Attributes["font-size"] == null) ? SvgUnit.Empty : (SvgUnit)this.Attributes["font-size"]; }
            set { this.Attributes["font-size"] = value; }
        }

        /// <summary>
        /// Refers to the style of the font.
        /// </summary>
        [SvgAttribute("font-style")]
85
        public override SvgFontStyle FontStyle
Eric Domke's avatar
Eric Domke committed
86
        {
87
            get { return (this.Attributes["font-style"] == null) ? SvgFontStyle.All : (SvgFontStyle)this.Attributes["font-style"]; }
Eric Domke's avatar
Eric Domke committed
88
89
90
91
92
93
94
            set { this.Attributes["font-style"] = value; }
        }

        /// <summary>
        /// Refers to the varient of the font.
        /// </summary>
        [SvgAttribute("font-variant")]
95
        public override SvgFontVariant FontVariant
Eric Domke's avatar
Eric Domke committed
96
        {
97
            get { return (this.Attributes["font-variant"] == null) ? SvgFontVariant.Inherit : (SvgFontVariant)this.Attributes["font-variant"]; }
Eric Domke's avatar
Eric Domke committed
98
99
100
101
102
103
104
            set { this.Attributes["font-variant"] = value; }
        }

        /// <summary>
        /// Refers to the boldness of the font.
        /// </summary>
        [SvgAttribute("font-weight")]
105
        public override SvgFontWeight FontWeight
Eric Domke's avatar
Eric Domke committed
106
        {
107
            get { return (this.Attributes["font-weight"] == null) ? SvgFontWeight.Inherit : (SvgFontWeight)this.Attributes["font-weight"]; }
Eric Domke's avatar
Eric Domke committed
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
            set { this.Attributes["font-weight"] = value; }
        }

        [SvgAttribute("panose-1")]
        public string Panose1
        {
            get { return this.Attributes["panose-1"] as string; }
            set { this.Attributes["panose-1"] = value; }
        }

        [SvgAttribute("units-per-em")]
        public float UnitsPerEm
        {
            get { return (this.Attributes["units-per-em"] == null ? 1000 : (float)this.Attributes["units-per-em"]); }
            set { this.Attributes["units-per-em"] = value; }
        }

        [SvgAttribute("x-height")]
        public float XHeight
        {
            get { return (this.Attributes["x-height"] == null ? float.MinValue : (float)this.Attributes["x-height"]); }
            set { this.Attributes["x-height"] = value; }
        }


        public override SvgElement DeepCopy()
        {
            return base.DeepCopy<SvgFontFace>();
        }
    }
}