prawn-table icon indicating copy to clipboard operation
prawn-table copied to clipboard

Change movement depending on vertical table alignment

Open rsynnest opened this issue 4 years ago • 2 comments

This is a potential fix for #127

It's a cheeky fix, but I think the end result is much better.

Before: image

After: image

Test PDF was generated using this code:

Prawn::Document.generate('result.pdf') do

data = [ ["TOP", "", ""], ]
table data, :cell_style => { :valign => :top}
move_down 20

data = [ ["CENTER", "", ""], ]
table data, :cell_style => { :valign => :center}
move_down 20

data = [ ["BOTTOM", "", ""], ]
table data, :cell_style => { :valign => :bottom}
move_down 20

end

rsynnest avatar Sep 05 '21 19:09 rsynnest

Here is a PDF showing the results rendered for the 15 built-in Prawn fonts: result.pdf

The only ones that have a problem are Symbol and ZapfDingbats, but those would also blow up with the pre-PR code, because the bottom-alignment code is unchanged.

rsynnest avatar Sep 05 '21 19:09 rsynnest

Someone let me know that TTF fonts might have negative results after this change. I went ahead and generated a PDF using 310 TTF fonts available in Windows 10.

Before this PR: before.pdf

After this PR: after.pdf

Most TTF fonts appear to benefit from this PR, and at the worst, they remain the same broken result as before the PR (usually Top and Center are just too low). I given that valign seems to be broken currently for ALL fonts, including the builtin ones, this fix at least fixes built in fonts, and seems to also benefit most TTF fonts in testing.

rsynnest avatar Sep 06 '21 00:09 rsynnest