Skip to content

Commit

Permalink
Fix the width repartition between columns when sum(preferred_widths) = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed May 11, 2012
1 parent f1da53a commit b3a91e4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions weasyprint/layout/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,17 @@ def auto_table_layout(box, containing_block, absolute_boxes):

lost_width = table.width - sum(table.column_widths) - all_border_spacing
if lost_width > 0:
table.column_widths = [
(column_width + lost_width * preferred_column_width /
sum(column_preferred_widths))
for (preferred_column_width, column_width)
in zip(column_preferred_widths, table.column_widths)]
sum_column_preferred_widths = sum(column_preferred_widths)
if sum_column_preferred_widths:
table.column_widths = [
(column_width + lost_width * preferred_column_width /
sum_column_preferred_widths)
for (preferred_column_width, column_width)
in zip(column_preferred_widths, table.column_widths)]
else:
table.column_widths = [
column_width + lost_width / len(table.column_widths)
for column_width in table.column_widths]


def table_wrapper_width(wrapper, containing_block, absolute_boxes):
Expand Down

0 comments on commit b3a91e4

Please sign in to comment.