>From 6fe0dbd45df97cf08608d90e5e8b4571f097da71 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 20 Sep 2015 18:38:40 +0200 Subject: [PATCH 3/3] Make columns in PDF tables wide enough for their widest text Fix the columns width in case the widest text of the column is wider than the column header. Previously, the "em" margins were only added if the column header was wider, but they need to be added in any case because the column would look too cramped otherwise and also because the margin is used when rendering it, which resulted in wrong display if it wasn't taken into account when determining its width. --- wx_table_generator.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp index 3d9a08f..d6dfd16 100644 --- a/wx_table_generator.cpp +++ b/wx_table_generator.cpp @@ -126,14 +126,13 @@ void increase_to_if_smaller(T& first, T second) increase_to_if_smaller(max_header_lines_, count_lines(header)); // Also increase the column width to be sufficiently wide to fit - // this header line (with roughly 1 em margins on either side) if it has - // fixed width. + // this header line if it has fixed width. if(0 != width) { - increase_to_if_smaller - (width - ,dc_.GetMultiLineTextExtent(header).x + dc_.GetTextExtent("MM").x - ); + increase_to_if_smaller(width, dc_.GetMultiLineTextExtent(header).x); + + // Add add roughly 1 em margins on both sides. + width += dc_.GetTextExtent("MM").x; } columns_.push_back(column_info(header, width)); -- 2.5.1