summaryrefslogtreecommitdiffstats
path: root/print.c
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2013-02-01 14:58:43 +1100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-01 16:11:47 +1100
commita6fd4076267be5aabe8adc7da56105e520371476 (patch)
tree66bec4a3d89d0822fff402503d9ce0071abf9bdb /print.c
parent7e7cbb0dce33f8527cb348e020f4800b0482f39e (diff)
downloadsubsurface-a6fd4076267be5aabe8adc7da56105e520371476.tar.gz
print: Use cairo_save/cairo_restore to manage temporary cairo changes
The print_weight_data function was making several cairo_translate calls and then doing some final cairo_translate calls with the goal of manually undoing any changes to cairo's state. Obviously, this is fragile. Cairo provides save/restore calls which solve this problem in a robust way. Switch to using these instead. Signed-off-by: Carl Worth <cworth@cworth.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'print.c')
-rw-r--r--print.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/print.c b/print.c
index 222bf8d43..50147f78a 100644
--- a/print.c
+++ b/print.c
@@ -290,6 +290,8 @@ static void print_weight_data (struct dive *dive, cairo_t *cr, int maxwidth, int
char buffer[80];
PangoLayout *layout;
+ cairo_save(cr);
+
layout = pango_cairo_create_layout(cr);
pango_layout_set_height(layout,maxheight);
pango_layout_set_width(layout, maxwidth);
@@ -339,10 +341,9 @@ static void print_weight_data (struct dive *dive, cairo_t *cr, int maxwidth, int
unit_weight);
pango_layout_set_text(layout, buffer, -1);
pango_cairo_show_layout(cr, layout);
- /* undo translations */
- cairo_translate (cr, 0, -(weightsystemcounter * height) / (4 * (double) PANGO_SCALE));
- cairo_translate (cr, 0, -height / (3 * (double) PANGO_SCALE));
g_object_unref (layout);
+
+ cairo_restore(cr);
}
/* Print the dive OTUs */