lib/rabbit/theme/image/image.rb in rabbit-2.1.8 vs lib/rabbit/theme/image/image.rb in rabbit-2.1.9

- old
+ new

@@ -38,38 +38,40 @@ images.padding_bottom = padding_bottom draw_frame(images, params) if @image_with_frame images.each do |image| - unless image.caption - image.margin_bottom = @space + image.margin_bottom = @space + + caption_text = image.caption + if caption_text.nil? or caption_text.empty? next end - + layout = nil - th = 0 + caption_height = 0 image.add_post_draw_proc(proc_name) do |canvas, x, y, w, h, simulation| if simulation - caption = Text.new(image.caption) + caption = Text.new(caption_text) caption.prop_set("size", @image_caption_font_size) set_font_family(caption) if image.horizontal_centering caption.do_horizontal_centering(canvas, x, y, w, h) end caption.compile(canvas, image.ox || x, y, image.ow || w, h) layout = caption.layout - th = caption.height - - margin_bottom = @space + th - image.margin_bottom = margin_bottom + caption_height = caption.height end if !simulation and layout base_x = image.ox || x base_y = y caption_color = image["caption-color"] || @image_caption_color - canvas.draw_layout(layout, base_x, base_y, caption_color) + canvas.draw_layout(layout, + base_x, + base_y + image.margin_bottom, + caption_color) end - [x, y, w, h] + [x, y + caption_height, w, h - caption_height] end end end