diff options
author | Salvador Cuñat <salvador.cunat@gmail.com> | 2013-02-23 10:44:45 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-23 08:21:49 -0800 |
commit | f47813546cc481a69cce741dc04ad72e7fc1ca55 (patch) | |
tree | b2a74cbbc7131c12d289754df70fd0ba7db659e8 /print.c | |
parent | 0eb53fab52acdcca60a3a80d4d0d9e1e9fffb38b (diff) | |
download | subsurface-f47813546cc481a69cce741dc04ad72e7fc1ca55.tar.gz |
Print.c : fixes problem with line height in print_tanks
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 <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'print.c')
-rw-r--r-- | print.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -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); |