1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Swiffy v7.2のテキスト改行がおかしくなる件

1
Last updated at Posted at 2015-07-15

Google Swiffyは死にました。この記事はゴミになりました。

Swiffyのテキスト改行がおかしくなる件
Swiffyって何? → Swiffy | Google Developers

↓こういう状態
(左がバグ状態、右が修正済みの状態です)
20150716-000416-8000.png

とりあえずどこを直せばいいのか書いておく。

runtime.js
    g.Ix = function(a, b, c, d) {
        for (var e = this.Zo(), f = 0; f < a.length;) {
            for (var h = f + 1, k = a.length, m; k > h;) {
                var n = h + (k - h) / 2,
                    n = Math.ceil(n);
                m = a.substring(f, n);
                e.measureText(m).width <= b - c ? h = n : k = n - 1
            }
// console.log('"' + a + '".substr('+f+','+h+'); => ' + a.substr(f, h));
// console.log('"' + a + '".substring('+f+','+h+'); => ' + a.substring(f, h));

//            d.push(a.substr(f, h)); // ← この行がバグ
            d.push(a.substring(f, h)); // これが本来期待する動作
            f = h;
            c = 0
        }
    };

substrとsubstringを勘違いしてただけっていうね…
余談ですが、整形した時に2万行超えてて発狂しそうになりました。(+コードの難読化)

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?