From f47813546cc481a69cce741dc04ad72e7fc1ca55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20Cu=C3=B1at?= Date: Sat, 23 Feb 2013 10:44:45 +0100 Subject: [PATCH] Print.c : fixes problem with line height in print_tanks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A "\n" was giving 2 lines height for the layout. Wipping it out makes unnecesary the *2 divisor. As there may be wrapped strings in tank we need to take account of this height. There is no need, really, to get the height of the gasmix or gas_consumed strings, as they are "semi-fixed" size, but under some locales and imperial units they could be wrapped too. Signed-off-by: Salvador Cuñat Signed-off-by: Dirk Hohndel --- print.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/print.c b/print.c index 169c22f7c..ebb80eb2d 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);