[glabels] Use line spacing when automatically adjusting font size.



commit 83977eda4a92c19f4f8ae44879d5041231b84f80
Author: Jim Evins <evins snaught com>
Date:   Sat Jul 14 07:59:08 2012 -0400

    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 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/label-text.c b/src/label-text.c
index 5ad9e9e..06f520d 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]