From 649e5dca466091d32bccf674d3dd308fe1aa62a6 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sat, 17 Dec 2016 23:39:02 -0700 Subject: [PATCH] resolves #295 calculate height of inline image correctly in table cell (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 --- .../formatted_text/inline_image_arranger.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb b/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb index 39b5e3f27..9f9cd25b3 100644 --- a/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb +++ b/lib/asciidoctor-pdf/formatted_text/inline_image_arranger.rb @@ -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