prawnpdf/prawn — pull request #576 by sigmike (2013-11-18 12:53:35+00:00)
Title: Fix span widths

Following my comment on https://github.com/prawnpdf/prawn/issues/407#issuecomment-28556698

To make the spec pass I rewrote the way width is distributed on cells with colspan > 1.
Before that it allocated space evenly, which is a problem when other cells in a table already have allocated space.

For example this table:

| aaa | b |
| c |

If "aaa" has a width of 150, "b" and "c" a width of 50, and the column widths are set to 150 and 50, then there's room for everything.
Without the patch it would allocate 150 to the first column, and 100 to the second one (total width 200 / colspan 2).

With the patch it allocates widths in 2 passes:
* first only allocate width for cells with colspan == 1
* then for cells with colspan > 1: distribute only the width that does not fit in the already allocate widths

I made the same change for height but it probably needs a spec.

I also had to change the way extra space in table is distributed.