Commit e0c60ad

mo khan <mo@mokhan.ca>
2015-04-08 22:07:17
add text attributes.
1 parent 21bdd0a
Changed files (4)
lib/scale/node.rb
@@ -5,6 +5,7 @@ module Scale
     include Enumerable
     include Virtus.module
     attr_reader :content
+    attribute :style, String
 
     def children
       @children ||= []
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)
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
 
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