gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-


From: Bastiaan Jacques
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-1682-g51959a7
Date: Tue, 23 Jul 2013 12:01:08 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  51959a760e5ca622f88373f5476031d75bfb8a3e (commit)
       via  01fbb6ad7f923f5e091f6a531bbfccdd084b0426 (commit)
       via  1f94251094279e59423635cc613f1e71419c8faf (commit)
       via  f9b638ef41dc94575196f517a2ad37f04d42b7f0 (commit)
      from  bcb6742f5dec095baa6f52f0b8cb52b2ba8bf297 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=51959a760e5ca622f88373f5476031d75bfb8a3e


commit 51959a760e5ca622f88373f5476031d75bfb8a3e
Author: Bastiaan Jacques <address@hidden>
Date:   Tue Jul 23 14:00:56 2013 +0200

    Tidy up.

diff --git a/libcore/asobj/TextFormat_as.cpp b/libcore/asobj/TextFormat_as.cpp
index 0e07e95..d540e8c 100644
--- a/libcore/asobj/TextFormat_as.cpp
+++ b/libcore/asobj/TextFormat_as.cpp
@@ -615,14 +615,14 @@ textformat_getTextExtent(const fn_call& fn)
     /// 240 twips for a size 12.
     const double scale = size / static_cast<double>(f->unitsPerEM(em));
 
-    // If the text is empty, size is 0. Otherwise we start with the font
-    // size.
     double width = 0;
     double curr = 0;
 
     const double ascent = f->ascent(em) * scale;
     const double descent = f->descent(em) * scale;
-    double height = ascent + descent;
+    // If the text is empty, height is 0. Otherwise we start with the font
+    // size.
+    double height = s.empty() ? 0 : ascent + descent;
 
     bool limitWidthSet = true;
     if (version < 8 && limitWidth) {

http://git.savannah.gnu.org/cgit//commit/?id=01fbb6ad7f923f5e091f6a531bbfccdd084b0426


commit 01fbb6ad7f923f5e091f6a531bbfccdd084b0426
Author: Bastiaan Jacques <address@hidden>
Date:   Tue Jul 23 13:51:36 2013 +0200

    Add some tests, and expect many successes.

diff --git a/testsuite/actionscript.all/TextFormat.as 
b/testsuite/actionscript.all/TextFormat.as
index 9193125..da36113 100644
--- a/testsuite/actionscript.all/TextFormat.as
+++ b/testsuite/actionscript.all/TextFormat.as
@@ -332,22 +332,45 @@ check(te.hasOwnProperty("textFieldHeight"));
 check(te.hasOwnProperty("width"));
 check(te.hasOwnProperty("height"));
 
-xcheck_equals(Math.round(te.textFieldWidth), 37);
+check_equals(Math.round(te.textFieldWidth), 37);
+check_equals(Math.round(te.width), 33);
 check_equals(Math.round(te.ascent), 11);
 
 #if OUTPUT_VERSION > 7
- xcheck_equals(Math.round(te.textFieldHeight), 18); 
+ check_equals(Math.round(te.textFieldHeight), 18); 
  check_equals(Math.round(te.descent), 3); 
 #else
- xcheck_equals(Math.round(te.textFieldHeight), 17); 
- xcheck_equals(Math.round(te.descent), 2); 
+ check_equals(Math.round(te.textFieldHeight), 17); 
+ check_equals(te.descent, 2); 
 #endif
 
+te = tf2.getTextExtent("a");
+check_equals(Math.round(te.width), 8); 
+te = tf2.getTextExtent("aa");
+check_equals(Math.round(te.width), 16); 
+te = tf2.getTextExtent("aaa");
+check_equals(Math.round(te.width), 24); 
+
 te = tf2.getTextExtent("Hello", 10);
 #if OUTPUT_VERSION > 7
- xcheck_equals(Math.round(te.textFieldHeight), 74);
+ check_equals(Math.round(te.textFieldHeight), 74);
 #else
- xcheck_equals(Math.round(te.textFieldHeight), 17);
+ check_equals(Math.round(te.textFieldHeight), 17);
+#endif
+
+#if OUTPUT_VERSION == 7
+ var wrappingPoint = 0;
+ for (var i:Number = 10; i < 30; i++) {
+     if (tf2.getTextExtent("Hello", i).height != 13) {
+        wrappingPoint = i;
+        break;
+     }
+ }
+
+ // Wrapping is enabled only if the wrapping value >= tfw of the first two
+ // letters. Doh.
+ check_equals(wrappingPoint, tf2.getTextExtent("He").textFieldWidth );
+ check_equals(tf2.getTextExtent("Hello", wrappingPoint).height, 27);
 #endif
 
 check_equals(te.textFieldWidth, 10);
@@ -355,16 +378,16 @@ check_equals(te.textFieldWidth, 10);
 #if OUTPUT_VERSION > 7
 check_equals(Math.round(te.width), 9);
 #else
-xcheck_equals(Math.round(te.width), 33);
+check_equals(Math.round(te.width), 33);
 #endif
 
 
 te = tf2.getTextExtent("Hello", 5);
 #if OUTPUT_VERSION < 8
- xcheck_equals(Math.round(te.textFieldHeight), 17);
- xcheck_equals(Math.round(te.descent), 2); 
+ check_equals(Math.round(te.textFieldHeight), 17);
+ check_equals(te.descent, 2); 
 #else
- xcheck_equals(Math.round(te.textFieldHeight), 74);
+ check_equals(Math.round(te.textFieldHeight), 74);
  check_equals(Math.round(te.descent), 3);
 #endif
 check_equals(te.textFieldWidth, 5);
@@ -374,59 +397,69 @@ check_equals(Math.round(te.ascent), 11);
 // Width of largest character in version 8?
 check_equals(Math.round(te.width), 9);
 #else
-xcheck_equals(Math.round(te.width), 33);
+check_equals(Math.round(te.width), 33);
 #endif
 
 
 te = tf2.getTextExtent("Longer sentence with more words.", 30);
 check_equals(te.textFieldWidth, 30);
-xcheck_equals(Math.round(te.width), 25);
+check_equals(Math.round(te.width), 25);
 #if OUTPUT_VERSION > 7
 xcheck_equals(te.height, 152.9);
 #else
 xcheck_equals(te.height, 152);
 #endif
 
+te = tf2.getTextExtent("Longersentencewithoneword", 30);
+check_equals(te.textFieldWidth, 30);
+#if OUTPUT_VERSION > 7
+xcheck_equals(te.height, 125.1);
+xcheck_equals(Math.round(te.width), 25);
+#else
+check_equals(te.width, 26);
+check_equals(te.height, 111);
+#endif
+
 te = tf2.getTextExtent("o");
-xcheck_equals(Math.round(te.textFieldWidth), 12);
+check_equals(Math.round(te.textFieldWidth), 12);
 check_equals(Math.round(te.ascent), 11);
 #if OUTPUT_VERSION < 8
- xcheck_equals(Math.round(te.textFieldHeight), 17); 
- xcheck_equals(Math.round(te.descent), 2); 
+ check_equals(Math.round(te.textFieldHeight), 17); 
+ check_equals(te.descent, 2); 
 #else
- xcheck_equals(Math.round(te.textFieldHeight), 18); 
+ check_equals(Math.round(te.textFieldHeight), 18); 
  check_equals(Math.round(te.descent), 3); 
 #endif
 
 te = tf2.getTextExtent("oo");
-xcheck_equals(Math.round(te.textFieldWidth), 20);
+check_equals(Math.round(te.textFieldWidth), 20);
 check_equals(Math.round(te.ascent), 11);
 #if OUTPUT_VERSION < 8
- xcheck_equals(Math.round(te.textFieldHeight), 17); 
- xcheck_equals(Math.round(te.descent), 2); 
+ check_equals(Math.round(te.textFieldHeight), 17); 
+ check_equals(te.descent, 2); 
 #else
- xcheck_equals(Math.round(te.textFieldHeight), 18); 
+ check_equals(Math.round(te.textFieldHeight), 18); 
  check_equals(Math.round(te.descent), 3); 
 #endif
 
 te = tf2.getTextExtent("ool");
-xcheck_equals(Math.round(te.textFieldWidth), 24);
+check_equals(Math.round(te.textFieldWidth), 24);
 check_equals(Math.round(te.ascent), 11);
 #if OUTPUT_VERSION < 8
- xcheck_equals(Math.round(te.textFieldHeight), 17); 
- xcheck_equals(Math.round(te.descent), 2); 
+ check_equals(Math.round(te.textFieldHeight), 17); 
+ check_equals(te.descent, 2); 
 #else
- xcheck_equals(Math.round(te.textFieldHeight), 18); 
+ check_equals(Math.round(te.textFieldHeight), 18); 
  check_equals(Math.round(te.descent), 3); 
 #endif
 
 tf2.size = 20;
 te = tf2.getTextExtent("ool");
-xcheck_equals(Math.round(te.textFieldHeight), 27);
-xcheck_equals(Math.round(te.textFieldWidth), 36);
+check_equals(Math.round(te.textFieldHeight), 27);
+check_equals(Math.round(te.textFieldWidth), 36);
 #if OUTPUT_VERSION < 8
- xcheck_equals(Math.round(te.ascent), 18); 
- xcheck_equals(Math.round(te.descent), 4); 
+ check_equals(te.ascent, 18); 
+ check_equals(te.descent, 4); 
 #else
  check_equals(Math.round(te.ascent), 19); 
  check_equals(Math.round(te.descent), 5);
@@ -437,7 +470,7 @@ xcheck_equals(Math.round(te.textFieldWidth), 36);
 #if OUTPUT_VERSION < 7
     check_totals(122);
 #elif OUTPUT_VERSION == 7
-    check_totals(159);
+    check_totals(168);
 #else 
-    check_totals(159);
+    check_totals(166);
 #endif

http://git.savannah.gnu.org/cgit//commit/?id=1f94251094279e59423635cc613f1e71419c8faf


commit 1f94251094279e59423635cc613f1e71419c8faf
Author: Bastiaan Jacques <address@hidden>
Date:   Tue Jul 23 13:51:00 2013 +0200

    Improve the implementation of getTextExtent.

diff --git a/libcore/asobj/TextFormat_as.cpp b/libcore/asobj/TextFormat_as.cpp
index ce94ef6..0e07e95 100644
--- a/libcore/asobj/TextFormat_as.cpp
+++ b/libcore/asobj/TextFormat_as.cpp
@@ -570,11 +570,11 @@ textformat_getTextExtent(const fn_call& fn)
     const int version = getSWFVersion(fn);
     const std::string& s = fn.arg(0).to_string(version);
 
-    const bool limitWidth = (fn.nargs > 1);
+    bool limitWidth = (fn.nargs > 1);
     
     // Everything must be in twips here.
     const double tfw = limitWidth ?
-        pixelsToTwips(toNumber(fn.arg(1), getVM(fn))) : 0;
+        pixelsToTwips(toNumber(fn.arg(1), getVM(fn)) - 4) : 0;
 
     const bool bold = relay->bold() ? *relay->bold() : false;
     const bool italic = relay->italic() ? *relay->italic() : false;
@@ -617,40 +617,66 @@ textformat_getTextExtent(const fn_call& fn)
 
     // If the text is empty, size is 0. Otherwise we start with the font
     // size.
-    double height = s.empty() ? 0 : size;
     double width = 0;
     double curr = 0;
 
     const double ascent = f->ascent(em) * scale;
     const double descent = f->descent(em) * scale;
+    double height = ascent + descent;
+
+    bool limitWidthSet = true;
+    if (version < 8 && limitWidth) {
+        limitWidth = false;
+        limitWidthSet = false;
+    }
 
     for (std::string::const_iterator it = s.begin(), e = s.end();
             it != e; ++it) {
 
         const int index = f->get_glyph_index(*it, em);
-        const double advance = f->get_advance(index, em) * scale;
-        if (limitWidth && (curr + advance > tfw)) {
+        double advance = f->get_advance(index, em) * scale;
+        // Snap advance to the nearest pixel boundary.
+        advance = ((int)advance + 19) / 20 * 20;
+
+        if (limitWidth && (curr + advance > tfw) && it != s.begin() ) {
             curr = 0;
-            height += size;
+            height += ascent + descent;
         }
         curr += advance;
         width = std::max(width, curr);
 
+        if (!limitWidthSet) {
+            // For v7, wrapping is enabled only if the limit param is greater
+            // than or equal to the width of the first two letters (plus the
+            // 4-pixel padding, which has been subtracted from tfw).
+            if (std::distance(s.begin(), it) == 1) {
+               limitWidth = (tfw >= width);
+               limitWidthSet = true;
+            }
+        }
     }
 
     Global_as& gl = getGlobal(fn);
     as_object* obj = new as_object(gl);
 
-    obj->init_member("textFieldHeight", twipsToPixels(height) + 4);
     obj->init_member("textFieldWidth",
-            limitWidth ? twipsToPixels(tfw) : twipsToPixels(width) + 4);
+            (fn.nargs > 1) ? twipsToPixels(tfw) + 4 : twipsToPixels(width) + 
4);
     obj->init_member("width", twipsToPixels(width));
-    obj->init_member("height", twipsToPixels(height));
-    obj->init_member("ascent", twipsToPixels(ascent));
-    obj->init_member("descent", twipsToPixels(descent));
 
-    return as_value(obj);
+    double ascentPixels = twipsToPixels(ascent);
+    double descentPixels = twipsToPixels(descent);
+    double heightPixels = twipsToPixels(height);
+    if (version < 8) {
+        ascentPixels = std::floor(ascentPixels);
+        descentPixels = std::floor(descentPixels);
+        heightPixels = std::floor(heightPixels);
+    }
+    obj->init_member("ascent", ascentPixels);
+    obj->init_member("descent", descentPixels);
+    obj->init_member("height", heightPixels);
+    obj->init_member("textFieldHeight", heightPixels + 4);
 
+    return as_value(obj);
 }
 
 

http://git.savannah.gnu.org/cgit//commit/?id=f9b638ef41dc94575196f517a2ad37f04d42b7f0


commit f9b638ef41dc94575196f517a2ad37f04d42b7f0
Author: Bastiaan Jacques <address@hidden>
Date:   Tue Jul 23 13:50:29 2013 +0200

    Fix typo.

diff --git a/libcore/swf/DefineFontTag.cpp b/libcore/swf/DefineFontTag.cpp
index 0fa31e7..4ad7954 100644
--- a/libcore/swf/DefineFontTag.cpp
+++ b/libcore/swf/DefineFontTag.cpp
@@ -285,7 +285,7 @@ DefineFontTag::readDefineFont2Or3(SWFStream& in, 
movie_definition& m,
         in.ensureBytes(nGlyphs*2);
 
         for (size_t i = 0; i < nGlyphs; i++) {
-            // This is documented to be unsigned, but then we get negative
+            // This is documented to be signed, but then we get negative
             // advances for subpixel fonts because the advance overflows
             // int16_t.
             _glyphTable[i].advance = static_cast<float>(in.read_u16());

-----------------------------------------------------------------------

Summary of changes:
 libcore/asobj/TextFormat_as.cpp          |   54 +++++++++++++-----
 libcore/swf/DefineFontTag.cpp            |    2 +-
 testsuite/actionscript.all/TextFormat.as |   93 ++++++++++++++++++++----------
 3 files changed, 104 insertions(+), 45 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]