[PATCH] Print.c : fixes problem with line height in print_tanks

Salvador Cuñat salvador.cunat at gmail.com
Sat Feb 23 11:00:08 PST 2013


On Sat, Feb 23, 2013 at 04:41:11PM +0200, Lubomir I. Ivanov wrote:
> 
> it seems your patch is DOS/ANSI instead of UNIX/UTF-8. could you
> configure your commit message editor to conform with that?
> 
Try this one, please Lubomir, it's made with git gui while the other was
made with gitg, and perhaps ...

> the line spacing between tanks looks fixed now, nice work.
>
I'm ashamed with my own stupidity.

> here is the table print:
> http://i45.tinypic.com/2lw61xw.gif
> there seem to be doubling of the column titles, also the padding
> bellow them is incorrect. my locale is (bg_BG).
>
I'm getting the same printout with 3.0, but only in win32,  double header
and the strings wrapped instead of ellipsized, even in english, as my
win version appears not to localize to spanish (???).  

> i could be wrong, but i think the "doubling" happened after dirk made
> some changes somewhere in these patches:
>
The doubling may be, but the wrapping was even previous to the changes.

Regards

Salva.

-------------- next part --------------
commit 3d9f958b5e98ce8d72ac6bf0da1e48790904c1c5
Author: Salvador Cu?at <salvador.cunat at gmail.com>
Date:   Fri Feb 22 18:41:25 2013 +0100

    Print.c : fixes problem with line height in print_tanks
    
    A "\n" was giving 2 lines size in linux, but not in win.
    Wipping it out makes unnecesary the *2 divisor.
    As there may be two lines string in tank we need to take account
    of it.
    
    Signed-off-by: Salvador Cu?at <salvador.cunat at gmail.com>

diff --git a/print.c b/print.c
index 169c22f..ebb80eb 100644
--- a/print.c
+++ b/print.c
@@ -197,7 +197,7 @@ static void print_tanks (struct dive *dive, cairo_t *cr, PangoLayout *layout, in
 		int tank_count, int first_tank, PangoFontDescription *font,
         double w_scale_factor)
 {
-	int curwidth, n, i, counter;
+	int curwidth, n, i, counter, height_count = 0;
 	char buffer[80], dataheader1[3][80]= { N_("Cylinder"), N_("Gasmix"),
 	/*++GETTEXT Gas Used is amount used */
 					       N_("Gas Used")};
@@ -247,26 +247,38 @@ static void print_tanks (struct dive *dive, cairo_t *cr, PangoLayout *layout, in
 		snprintf(buffer, sizeof(buffer), "%s", desc);
 		pango_layout_set_text(layout, buffer, -1);
 		pango_cairo_show_layout(cr, layout);
+		pango_layout_get_extents(layout, NULL, &logic_ext);
+		if (logic_ext.height > height_count)
+			height_count = logic_ext.height;
+
 		curwidth += (maxwidth/ 3);
 
 		cairo_move_to(cr, curwidth / (double) PANGO_SCALE, 0);
 		print_ean_trimix (cr, layout,
 				cyl->gasmix.o2.permille/10,
 				cyl->gasmix.he.permille/10);
+		pango_layout_get_extents(layout, NULL, &logic_ext);
+		if (logic_ext.height > height_count)
+			height_count = logic_ext.height;
+
 		curwidth += (maxwidth/ 3);
 
 		cairo_move_to(cr, curwidth / (double) PANGO_SCALE, 0);
-		snprintf(buffer, sizeof(buffer), _("%.*f %s\n"),
+		snprintf(buffer, sizeof(buffer), _("%.*f %s"),
 			decimals,
 			gas_usage,
 			unit);
 		pango_layout_set_text(layout, buffer, -1);
 		pango_cairo_show_layout(cr, layout);
+		pango_layout_get_extents(layout, NULL, &logic_ext);
+		if (logic_ext.height > height_count)
+			height_count = logic_ext.height;
+
 		curwidth += (maxwidth/ 3);
 		n++;
 		counter++;
-		pango_layout_get_extents(layout, NULL, &logic_ext);
-		cairo_translate (cr, 0, logic_ext.height / (2*(double) PANGO_SCALE));
+
+		cairo_translate (cr, 0, height_count / (double) PANGO_SCALE);
 	}
 	g_object_unref (layout);
 	cairo_restore(cr);


More information about the subsurface mailing list