summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-04-08 16:07:17 -0600
committermo khan <mo@mokhan.ca>2015-04-08 16:07:17 -0600
commite0c60add6ba8bf20dbd25354653955d737cc8b46 (patch)
treea630df4113a57421308575d6adffa9582746517d
parent21bdd0a70c641745e95f508b429e591bda8297ed (diff)
add text attributes.
-rw-r--r--lib/scale/node.rb1
-rw-r--r--lib/scale/text.rb12
-rw-r--r--spec/dsl_spec.rb10
-rw-r--r--spec/node_spec.rb6
4 files changed, 21 insertions, 8 deletions
diff --git a/lib/scale/node.rb b/lib/scale/node.rb
index 21fd7da..37bceaa 100644
--- a/lib/scale/node.rb
+++ b/lib/scale/node.rb
@@ -5,6 +5,7 @@ module Scale
include Enumerable
include Virtus.module
attr_reader :content
+ attribute :style, String
def children
@children ||= []
diff --git a/lib/scale/text.rb b/lib/scale/text.rb
index 058e832..99a44d1 100644
--- a/lib/scale/text.rb
+++ b/lib/scale/text.rb
@@ -4,6 +4,18 @@ module Scale
attribute :x, Integer
attribute :y, Integer
+ attribute :font_family, String
+ attribute :font_style, String
+ attribute :font_weight, String
+ attribute :font_variant, String
+ attribute :font_stretch, String
+ attribute :font_size, String
+ attribute :font_size_adjust, String
+ attribute :kerning, String
+ attribute :letter_spacing, String
+ attribute :word_spacing, String
+ attribute :text_decoration, String
+
def initialize(text, attributes = {})
@content = text
super(attributes)
diff --git a/spec/dsl_spec.rb b/spec/dsl_spec.rb
index 55d9f78..e4db45d 100644
--- a/spec/dsl_spec.rb
+++ b/spec/dsl_spec.rb
@@ -9,11 +9,11 @@ describe Scale::DSL do
end
expected = <<-XML
-<?xml version=\"1.0\"?>
-<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" baseProfile=\"full\">
- <rect width=\"100%\" height=\"100%\" fill=\"red\"/>
- <circle cx=\"150\" cy=\"100\" r=\"80\"/>
- <text x=\"150\" y=\"125\">SVG</text>
+<?xml version="1.0\"?>
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full">
+ <rect width="100%" height="100%" fill="red"/>
+ <circle cx="150" cy="100" r="80"/>
+ <text x="150" y="125" font-size="60">SVG</text>
</svg>
XML
diff --git a/spec/node_spec.rb b/spec/node_spec.rb
index c277dd6..b03bd4e 100644
--- a/spec/node_spec.rb
+++ b/spec/node_spec.rb
@@ -3,7 +3,7 @@ describe Scale::Node do
include Scale::Node
attribute :x, Integer
attribute :y, Integer
- attribute :fill_opacity, Float
+ attribute :font_size_adjust, Float
def xml_tag
:fake
@@ -45,10 +45,10 @@ describe Scale::Node do
end
it 'replaces underscores in attribute names' do
- subject.fill_opacity = 0.5
+ subject.font_size_adjust = 0.5
expected = <<-XML
<?xml version="1.0"?>
-<fake fill-opacity="0.5"/>
+<fake font-size-adjust="0.5"/>
XML
expect(subject.to_xml).to eql(expected)
end