FontFaceRule.cs 2.59 KB
Newer Older
Matt Schneeberger's avatar
Matt Schneeberger committed
1
2
using Svg.ExCSS.Model;
using Svg.ExCSS.Model.Extensions;
Eric Domke's avatar
Eric Domke committed
3
4

// ReSharper disable once CheckNamespace
Matt Schneeberger's avatar
Matt Schneeberger committed
5
namespace Svg.ExCSS
Eric Domke's avatar
Eric Domke committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
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
{
    public class FontFaceRule : RuleSet, ISupportsDeclarations
    {
        private readonly StyleDeclaration _declarations;

        public FontFaceRule() 
        {
            _declarations = new StyleDeclaration();
            RuleType = RuleType.FontFace;
        }

        internal FontFaceRule AppendRule(Property rule)
        {
            _declarations.Properties.Add(rule);
            return this;
        }

        public StyleDeclaration Declarations
        {
            get { return _declarations; }
        }

        public string FontFamily
        {
            get { return _declarations.GetPropertyValue("font-family"); }
            set { _declarations.SetProperty("font-family", value); }
        }

        public string Src
        {
            get { return _declarations.GetPropertyValue("src"); }
            set { _declarations.SetProperty("src", value); }
        }

        public string FontStyle
        {
            get { return _declarations.GetPropertyValue("font-style"); }
            set { _declarations.SetProperty("font-style", value); }
        }

        public string FontWeight
        {
            get { return _declarations.GetPropertyValue("font-weight"); }
            set { _declarations.SetProperty("font-weight", value); }
        }

        public string Stretch
        {
            get { return _declarations.GetPropertyValue("stretch"); }
            set { _declarations.SetProperty("stretch", value); }
        }

        public string UnicodeRange
        {
            get { return _declarations.GetPropertyValue("unicode-range"); }
            set { _declarations.SetProperty("unicode-range", value); }
        }

        public string FontVariant
        {
            get { return _declarations.GetPropertyValue("font-variant"); }
            set { _declarations.SetProperty("font-variant", value); }
        }

        public string FeatureSettings
        {
            get { return _declarations.GetPropertyValue("font-feature-settings"); }
            set { _declarations.SetProperty("font-feature-settings", value); }
        }

        public override string ToString()
        {
            return ToString(false);
        }

        public override string ToString(bool friendlyFormat, int indentation = 0)
        {
            return "@font-face{".NewLineIndent(friendlyFormat, indentation) +
                _declarations.ToString(friendlyFormat, indentation) +
                "}".NewLineIndent(friendlyFormat, indentation);
        }
    }
}