aboutsummaryrefslogtreecommitdiff
path: root/src/tool_text.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-10-04 23:18:26 +0200
committerThomas White <taw@bitwiz.org.uk>2011-10-04 23:18:26 +0200
commit064482aaaf0857cc0ad01b845558d84e1f684d58 (patch)
tree0857c50e47a12d933e04de57d8cbd13002505fe5 /src/tool_text.c
parent6d2a5a5bb0b7c2867331d7c77c6d4ee99967bcbc (diff)
Honour margins (right and bottom at least) for normal text as well
Diffstat (limited to 'src/tool_text.c')
-rw-r--r--src/tool_text.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/tool_text.c b/src/tool_text.c
index 88572af..f4df9a3 100644
--- a/src/tool_text.c
+++ b/src/tool_text.c
@@ -59,7 +59,7 @@ struct text_object
static void calculate_size_from_style(struct text_object *o,
double *peright, double *pebottom,
- double *pmw, double *pmh)
+ double *pmw, double *pmh, int furniture)
{
double max_width, max_height;
double ebottom, eright, mw, mh;
@@ -74,8 +74,12 @@ static void calculate_size_from_style(struct text_object *o,
*peright = eright; *pebottom = ebottom;
*pmw = mw; *pmh = mh;
- max_width = mw - o->base.style->margin_left
- - o->base.style->margin_right;
+ if ( furniture ) {
+ max_width = mw - o->base.style->margin_left
+ - o->base.style->margin_right;
+ } else {
+ max_width = eright - o->base.x;
+ }
/* Use the provided maximum width if it exists and is smaller */
if ( o->base.style->use_max_width
@@ -84,8 +88,12 @@ static void calculate_size_from_style(struct text_object *o,
max_width = o->base.style->max_width;
}
- max_height = mh - o->base.style->margin_top
- - o->base.style->margin_bottom;
+ if ( furniture ) {
+ max_height = mh - o->base.style->margin_top
+ - o->base.style->margin_bottom;
+ } else {
+ max_height = ebottom - o->base.y;
+ }
pango_layout_set_width(o->layout, max_width*PANGO_SCALE);
pango_layout_set_height(o->layout, max_height*PANGO_SCALE);
@@ -179,7 +187,7 @@ static void update_text(struct text_object *o)
o->fontdesc = pango_font_description_from_string(o->base.style->font);
pango_layout_set_font_description(o->layout, o->fontdesc);
- calculate_size_from_style(o, &eright, &ebottom, &mw, &mh);
+ calculate_size_from_style(o, &eright, &ebottom, &mw, &mh, furniture);
pango_layout_get_extents(o->layout, NULL, &logical);
o->base.bb_width = logical.width / PANGO_SCALE;