]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Add gfx_get_text_height function, to match width
authorAnders Björklund <anders@itension.se>
Sun, 26 Jun 2016 11:53:02 +0000 (13:53 +0200)
committerAnders Björklund <anders@itension.se>
Tue, 28 Jun 2016 16:32:16 +0000 (18:32 +0200)
src/rrd_gfx.c
src/rrd_graph.h

index 2c48c00ce40f8e7718a68d09c83ead181daf13ff..fa7b22337403c8076103031575779486e6373a6e 100644 (file)
@@ -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,
index c9522253a9e3ecac5cd05719a530e6a231cee863..7031cf956a2026247b6058172950a58cd9966668 100644 (file)
@@ -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(