Skip to content

Commit

Permalink
consolidate calculation of left position in convert_image
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Jun 27, 2023
1 parent b298e8c commit ee40e00
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/asciidoctor/pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1831,14 +1831,13 @@ def convert_image node, opts = {}
update_colors if graphic_state.color_space.empty?
ink_caption node, category: :image, end: :top, block_align: alignment, block_width: rendered_w, max_width: caption_max_width if caption_end == :top && node.title?
image_y = y
left = bounds.left
# NOTE: prawn-svg does not compute :at for alignment correctly in column box, so resort to our own logic
case alignment
when :center
left = bounds.left + (available_w - rendered_w) * 0.5
left += (available_w - rendered_w) * 0.5
when :right
left = bounds.left + available_w - rendered_w
else
left = bounds.left
left += available_w - rendered_w
end
svg_obj.options[:at] = [left, (image_cursor = cursor)]
svg_obj.draw # NOTE: cursor advances automatically
Expand Down

0 comments on commit ee40e00

Please sign in to comment.