From 83977eda4a92c19f4f8ae44879d5041231b84f80 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 14 Jul 2012 07:59:08 -0400 Subject: [PATCH] Use line spacing when automatically adjusting font size. Consider line spacing when automatically adjusting font size to keep within vertical dimension of bounding box. --- src/label-text.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/label-text.c b/src/label-text.c index 5ad9e9ec..06f520d3 100644 --- a/src/label-text.c +++ b/src/label-text.c @@ -171,6 +171,7 @@ static gdouble auto_shrink_font_size (cairo_t *cr, gdouble size, PangoWeight weight, PangoStyle style, + gdouble line_spacing, gchar *text, gdouble width, gdouble height); @@ -1017,7 +1018,7 @@ gl_label_text_get_auto_shrink (glLabelText *ltext) /*****************************************************************************/ -/* Automatically shrink text size to fit within horizontal width. */ +/* Automatically shrink text size to fit within bounding box. */ /*****************************************************************************/ static gdouble auto_shrink_font_size (cairo_t *cr, @@ -1025,6 +1026,7 @@ auto_shrink_font_size (cairo_t *cr, gdouble size, PangoWeight weight, PangoStyle style, + gdouble line_spacing, gchar *text, gdouble width, gdouble height) @@ -1046,8 +1048,9 @@ auto_shrink_font_size (cairo_t *cr, pango_layout_set_font_description (layout, desc); pango_font_description_free (desc); - pango_layout_set_text (layout, text, -1); + pango_layout_set_spacing (layout, size * (line_spacing-1) * PANGO_SCALE); pango_layout_set_width (layout, -1); + pango_layout_set_text (layout, text, -1); pango_layout_get_size (layout, &iw, &ih); layout_width = (gdouble)iw / (gdouble)PANGO_SCALE; layout_height = (gdouble)ih / (gdouble)PANGO_SCALE; @@ -1136,6 +1139,7 @@ set_text_path (glLabelText *this, font_size, this->priv->font_weight, style, + this->priv->line_spacing, text, object_w, object_h); -- 2.39.5