From: Anders Björklund Date: Sun, 26 Jun 2016 11:53:02 +0000 (+0200) Subject: Add gfx_get_text_height function, to match width X-Git-Tag: v1.7.0~44^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0ca7fd4acf435e2a6b54d457bb978e5dd3e8db5f;p=thirdparty%2Frrdtool-1.x.git Add gfx_get_text_height function, to match width --- diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index 2c48c00c..fa7b2233 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -20,6 +20,8 @@ #include "rrd_tool.h" #include "rrd_graph.h" +#include "unused.h" + /* create a new line */ void gfx_line( @@ -240,6 +242,22 @@ double gfx_get_text_width( return log_rect.width; } +double gfx_get_text_height( + image_desc_t *im, + double UNUSED(start), + PangoFontDescription *font_desc, + double tabwidth, + char *text) +{ + PangoLayout *layout; + PangoRectangle log_rect; + gfx_color_t color = { 0, 0, 0, 0 }; + layout = gfx_prep_text(im, 0.0, color, font_desc, tabwidth, text); + pango_layout_get_pixel_extents(layout, NULL, &log_rect); +/* g_object_unref(layout); */ + return log_rect.height; +} + void gfx_text( image_desc_t *im, double x, diff --git a/src/rrd_graph.h b/src/rrd_graph.h index c9522253..7031cf95 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -570,6 +570,14 @@ double gfx_get_text_width( double tabwidth, char *text); +/* measure height of a text string */ +double gfx_get_text_height( + image_desc_t *im, + double start, + PangoFontDescription *font_desc, + double tabwidth, + char *text); + /* convert color */ gfx_color_t gfx_hex_to_col(