Still in time to change the table print ?

Dirk Hohndel dirk at hohndel.org
Sat Feb 16 17:35:19 PST 2013


Salvador Cuñat <salvador.cunat at gmail.com> writes:

> Hi.
>
> Attached is the patch for the text positioning on table print.
>
> With my dives, and spanish locale, works correctly.
>
> Would need some test in other locales (specially cyrillic) and win/mac.
>
> Regards
>
> Salva.
> From 00fa8a1c9870b7bdba305dde2f1499cb369cf758 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Salvador=20Cu=C3=B1at?= <salvador.cunat at gmail.com>
> Date: Sun, 17 Feb 2013 00:25:04 +0100
> Subject: [PATCH] Little improvement on table print frame positioning.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> Tiny increment of the margins text/vertical divisors.
> Text centered in the rows height.
>
>
> Signed-off-by: Salvador Cuñat <salvador.cunat at gmail.com>
> ---
>  print.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/print.c b/print.c
> index 0aed20d..86b3301 100644
> --- a/print.c
> +++ b/print.c
> @@ -517,7 +517,7 @@ static int show_dive_table(struct dive *dive, cairo_t *cr, PangoLayout *layout,
>  	char buffer[160], divenr[20];
>  	PangoRectangle logic_ext;
>  
> -	maxwidth = w * PANGO_SCALE;
> +	maxwidth = w * 1.025 * PANGO_SCALE;
>  	colwidth = maxwidth / 7;

I don't think this is the correct fix. This makes the total width bigger.
>  
>  	cairo_move_to(cr, 0, 0);
> @@ -836,7 +836,7 @@ static void draw_table(GtkPrintOperation *operation,
>  		/* Write the dive data and get the max. height of the row */
>  		max_ext = show_dive_table(dive, cr, layout, w*2);
>  		/* Draw a frame for each row */
> -		print_table_frame (cr, -0.05, -0.02, w, max_ext / (double) PANGO_SCALE);
> +		print_table_frame (cr, -0.05, 0, w*1.025, max_ext / (double) PANGO_SCALE);

And then shifts things around. Now the columns no longer are the same
between the lines printed and the text printed.

I finally took the time to read through the code in more detail and
decided to spend the time to restructure it to make it easier to read
and maintain. Please look at what I just pushed out.

It works for me (tested with lots of dives and a couple of different
locales) but I'd really like for others to play with this as well.

/D


More information about the subsurface mailing list