Skip to content

Commit

Permalink
resolves #295 calculate height of inline image correctly in table cel…
Browse files Browse the repository at this point in the history
…l (PR #705)

- correctly distribute font height so cell allocates enough room for inline image
- incorrect distribution was leading to a negative line_gap, which was making cell too small
- applies to images whose height exceeds the line height threshold
  • Loading branch information
mojavelinux authored Dec 18, 2016
1 parent 2730cce commit 649e5dc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ def arrange_images fragments
# NOTE if image height exceeds line height by more than 1.5x, increase the line height
# FIXME we could really use a nicer API from Prawn here; this is an ugly hack
if (f_height = fragment[:image_height]) > ((line_font = doc.font).height * 1.5)
fragment[:ascender] = f_height
fragment[:descender] = line_font.descender
# align with descender (equivalent to vertical-align: bottom in CSS)
fragment[:ascender] = f_height - (fragment[:descender] = line_font.descender)
doc.font_size(fragment[:size] = f_height * (doc.font_size / line_font.height))
# align with baseline (roughly equivalent to vertical-align: baseline in CSS)
#fragment[:ascender] = f_height
#fragment[:descender] = 0
#doc.font_size(fragment[:size] = (f_height + line_font.descender) * (doc.font_size / line_font.height))
fragment[:line_height_increased] = true
end

Expand Down

0 comments on commit 649e5dc

Please sign in to comment.