From 38da6b4a0eacbe0c7e40bc5d237bf31030fcc57d Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 14 Jun 2010 11:59:33 +0100 Subject: [PATCH] clutter-text: Round the layout width to nearest integer not down When converting the floating point allocation width to an integer multiple of PANGO_SCALE to give to the PangoLayout it can sometimes end up slightly short of the allocated size due to rounding errors. This can cause some of the lines to be wrapped differently when a non-integer-aligned position is used (such as when animating text). It works better to round the number to the nearest integer by adding 0.5 instead of letting the default float cast truncate it downwards. http://bugzilla.openedhand.com/show_bug.cgi?id=2170 --- clutter/clutter-text.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index ccdb727c6..e9c227fad 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -532,7 +532,7 @@ clutter_text_create_layout (ClutterText *text, !((priv->editable && priv->single_line_mode) || (priv->ellipsize == PANGO_ELLIPSIZE_NONE && !priv->wrap)))) { - width = allocation_width * 1024; + width = allocation_width * 1024 + 0.5f; } /* Pango only uses height if ellipsization is enabled, so don't set @@ -549,7 +549,7 @@ clutter_text_create_layout (ClutterText *text, priv->ellipsize != PANGO_ELLIPSIZE_NONE && !priv->single_line_mode) { - height = allocation_height * 1024; + height = allocation_height * 1024 + 0.5f; } /* Search for a cached layout with the same width and keep