[Swfdec] libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c

Pekka Lampila medar at kemper.freedesktop.org
Mon Oct 29 09:38:00 PDT 2007


 libswfdec/swfdec_text_field_movie.c    |   10 ++++++++--
 libswfdec/swfdec_text_field_movie_as.c |    4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)

New commits:
commit 8f0b361eaa2bc5ce89b19494bfe88f4786dbcd97
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Mon Oct 29 17:06:28 2007 +0200

    Some more fixes to size handling in TextField

diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
index f10f529..13c5a75 100644
--- a/libswfdec/swfdec_text_field_movie.c
+++ b/libswfdec/swfdec_text_field_movie.c
@@ -783,6 +783,12 @@ swfdec_text_field_movie_get_text_size (SwfdecTextFieldMovie *text, int *width,
       *height += layouts[i].height;
   }
 
+  // align to get integer amount after TWIPS_TO_DOUBLE
+  if (width != NULL && *width % SWFDEC_TWIPS_SCALE_FACTOR != 0)
+    *width += SWFDEC_TWIPS_SCALE_FACTOR - *width % SWFDEC_TWIPS_SCALE_FACTOR;
+  if (height != NULL && *height % SWFDEC_TWIPS_SCALE_FACTOR != 0)
+    *height += SWFDEC_TWIPS_SCALE_FACTOR - *height % SWFDEC_TWIPS_SCALE_FACTOR;
+
   swfdec_text_field_movie_free_layouts (layouts);
 }
 
@@ -800,8 +806,8 @@ swfdec_text_field_movie_auto_size (SwfdecTextFieldMovie *text)
     return FALSE;
 
   swfdec_text_field_movie_get_text_size (text, &width, &height);
-  width += 2 * EXTRA_MARGIN;
-  height += 2 * EXTRA_MARGIN;
+  width += SWFDEC_DOUBLE_TO_TWIPS (2 * EXTRA_MARGIN);
+  height += SWFDEC_DOUBLE_TO_TWIPS (2 * EXTRA_MARGIN);
 
   if ((text->text->word_wrap ||
 	graphic->extents.x1 - graphic->extents.x0 == width) &&
diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
index dd5203f..248d878 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -424,7 +424,7 @@ swfdec_text_field_movie_get_textHeight (SwfdecAsContext *cx,
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
 
   swfdec_text_field_movie_get_text_size (text, NULL, &height);
-  SWFDEC_AS_VALUE_SET_NUMBER (ret, height);
+  SWFDEC_AS_VALUE_SET_NUMBER (ret, SWFDEC_TWIPS_TO_DOUBLE (height));
 }
 
 static void
@@ -438,7 +438,7 @@ swfdec_text_field_movie_get_textWidth (SwfdecAsContext *cx,
   SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
 
   swfdec_text_field_movie_get_text_size (text, &width, NULL);
-  SWFDEC_AS_VALUE_SET_NUMBER (ret, width);
+  SWFDEC_AS_VALUE_SET_NUMBER (ret, SWFDEC_TWIPS_TO_DOUBLE (width));
 }
 
 /*


More information about the Swfdec mailing list