lib/prawn/svg/element.rb in prawn-svg-0.15.0.0 vs lib/prawn/svg/element.rb in prawn-svg-0.16.0
- old
+ new
@@ -55,16 +55,27 @@
parse_opacity_attributes_and_call
parse_clip_path_attribute_and_call
draw_types = parse_fill_and_stroke_attributes_and_call
parse_stroke_width_attribute_and_call
parse_font_attributes_and_call
+ apply_drawing_call(draw_types)
+ end
- if draw_types.length > 0 && !@state[:disable_drawing] && !Prawn::Svg::Parser::CONTAINER_TAGS.include?(element.name)
- add_call_and_enter(draw_types.join("_and_"))
+ def apply_drawing_call(draw_types)
+ if !@state[:disable_drawing] && !container?
+ if draw_types.empty?
+ add_call_and_enter("end_path")
+ else
+ add_call_and_enter(draw_types.join("_and_"))
+ end
end
end
+ def container?
+ Prawn::Svg::Parser::CONTAINER_TAGS.include?(name)
+ end
+
def parse_transform_attribute_and_call
return unless transform = @attributes['transform']
parse_css_method_calls(transform).each do |name, arguments|
case name
@@ -127,33 +138,31 @@
add_call "clip"
end
end
def parse_fill_and_stroke_attributes_and_call
- draw_types = []
- [:fill, :stroke].each do |type|
- dec = @attributes[type.to_s]
+ ["fill", "stroke"].select do |type|
+ dec = @attributes[type]
if dec == "none"
- state[type] = false
+ state[type.to_sym] = false
elsif dec
- state[type] = true
+ state[type.to_sym] = true
if color = Prawn::Svg::Color.color_to_hex(dec)
add_call "#{type}_color", color
end
end
- draw_types << type.to_s if state[type]
+ state[type.to_sym]
end
- draw_types
end
def parse_stroke_width_attribute_and_call
add_call('line_width', @document.distance(@attributes['stroke-width'])) if @attributes['stroke-width']
end
def parse_font_attributes_and_call
if size = @attributes['font-size']
- @state[:font_size] = size.to_f * @document.scale
+ @state[:font_size] = size.to_f
end
if weight = @attributes['font-weight']
font_updated = true
@state[:font_weight] = Prawn::Svg::Font.weight_for_css_font_weight(weight)
end