summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Evins <evins@snaught.com>2012-07-14 07:59:08 -0400
committerJim Evins <evins@snaught.com>2012-07-14 07:59:08 -0400
commit83977eda4a92c19f4f8ae44879d5041231b84f80 (patch)
treef44efc196bdf7cdc2320af93bc5ff79dc8dcc858
parentaed8853e6e6007b9e18341da84b099a1ab9dda31 (diff)
Use line spacing when automatically adjusting font size.
Consider line spacing when automatically adjusting font size to keep within vertical dimension of bounding box.
-rw-r--r--src/label-text.c8
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);