lib/prawn/svg/element.rb in prawn-svg-0.20.0 vs lib/prawn/svg/element.rb in prawn-svg-0.21.0

- old
+ new

@@ -80,18 +80,21 @@ parse_css_method_calls(transform).each do |name, arguments| case name when 'translate' x, y = arguments - add_call_and_enter name, @document.distance(x, :x), -@document.distance(y, :y) + add_call_and_enter name, @document.distance(x.to_f, :x), -@document.distance(y.to_f, :y) when 'rotate' r, x, y = arguments.collect {|a| a.to_f} - if arguments.length == 3 + case arguments.length + when 1 + add_call_and_enter name, -r, :origin => [0, @document.y('0')] + when 3 add_call_and_enter name, -r, :origin => [@document.x(x), @document.y(y)] else - add_call_and_enter name, -r, :origin => [0, @document.y('0')] + @document.warnings << "transform 'rotate' must have either one or three arguments" end when 'scale' x_scale = arguments[0].to_f y_scale = (arguments[1] || x_scale).to_f @@ -140,17 +143,25 @@ end end def parse_fill_and_stroke_attributes_and_call ["fill", "stroke"].select do |type| - dec = @attributes[type] - if dec == "none" + case keyword = attribute_value_as_keyword(type) + when nil + when 'inherit' + when 'none' state[type.to_sym] = false - elsif dec - state[type.to_sym] = true - if color = Prawn::Svg::Color.color_to_hex(dec) - add_call "#{type}_color", color + else + color_attribute = keyword == 'currentcolor' ? 'color' : type + color = @attributes[color_attribute] + + begin + hex = Prawn::Svg::Color.color_to_hex(color) + state[type.to_sym] = true + add_call "#{type}_color", hex || '000000' + rescue Prawn::Svg::Color::UnresolvableURLWithNoFallbackError + state[type.to_sym] = false end end state[type.to_sym] end @@ -203,9 +214,12 @@ @state[:font_style] = style == 'italic' ? :italic : nil end if (family = @attributes['font-family']) && family.strip != "" font_updated = true @state[:font_family] = family + end + if (anchor = @attributes['text-anchor']) + @state[:text_anchor] = anchor end if @state[:font_family] && font_updated usable_font_families = [@state[:font_family], document.fallback_font_name]