From ff00d12a79791c544a07948446ae3039d9ddbb03 Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Wed, 4 Dec 2024 13:19:12 +0100 Subject: [PATCH] tests: Add avm2/edittext_getcharboundaries_missing_glyphs test This test verifies how getCharBoundaries() work when glyphs are missing. --- .../Test.as | 50 +++++++++++++ .../TestFont.ttf | Bin 0 -> 1600 bytes .../output.txt | 70 ++++++++++++++++++ .../test.swf | Bin 0 -> 2105 bytes .../test.toml | 1 + 5 files changed, 121 insertions(+) create mode 100644 tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/Test.as create mode 100644 tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/TestFont.ttf create mode 100644 tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/output.txt create mode 100644 tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/test.swf create mode 100644 tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/test.toml diff --git a/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/Test.as b/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/Test.as new file mode 100644 index 000000000000..3a83aa3c2bfd --- /dev/null +++ b/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/Test.as @@ -0,0 +1,50 @@ +package { +import flash.display.Sprite; +import flash.text.TextField; +import flash.text.TextFormat; + +[SWF(width="400", height="400")] +public class Test extends Sprite { + [Embed(source="TestFont.ttf", fontName="TestFont", embedAsCFF="false", unicodeRange="U+0061-U+0066")] + private var TestFont:Class; + + private var text:TextField; + + public function Test() { + stage.scaleMode = "noScale"; + text = new TextField(); + text.border = true; + text.x = 10; + text.y = 10; + text.width = 380; + text.height = 380; + text.multiline = true; + text.embedFonts = true; + addChild(text); + + testHtml("x y"); + testHtml("x y"); + testHtml("abcd ab"); + + text.wordWrap = true; + testHtml("

ab ab abababababa

"); + testHtml("

ab ab abababababab

"); + } + + private function testHtml(htmlText:String):void { + text.htmlText = htmlText; + trace("Text: " + htmlText.replace(/[\r\n]/g, "\\n")); + + testAt(-5); + testAt(-1); + for (var i = 0; i <= text.text.length; ++i) { + testAt(i); + } + } + + private function testAt(charIndex:int):void { + var bounds = text.getCharBoundaries(charIndex); + trace(" text.getCharBoundaries(" + charIndex + ") = " + bounds); + } +} +} diff --git a/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/TestFont.ttf b/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/TestFont.ttf new file mode 100644 index 0000000000000000000000000000000000000000..761128c1eb3c323d499229f8c34f7523983545de GIT binary patch literal 1600 zcmcgsOK4L;6g~4kX-ma^u!vA)9v1tdO<$5?t7K8s#!nGNLlIHzYnmp3{CG*Fbs;WA zL|loe3lYJc*n%MFJ}zB|t1e1cF6>g=RN|SJX>Gd@x^W)EoO|xQGw03R83+LTaStY@ z6N%)-H_u=80-+wV-Dl5CB+!Kew40TE>FRKF>h#FD9KThYr+ zA+Zr(<`%9;V;xRMZ>-~}BU--KYR0qQbB=LMZ*x#}JS&DcrrcOnoxjUnRuxG^U&QGO ze5wF=Yu|1iki;pC1#56#V}lAGX>6hgs~THq76&!9(I&<<4w0Wx6=JDc9A|G}fp(-c zHn{FxjZK`x6OApj3tM9wM}*WkME){Pql7XR;Uk9(vZz9$k8}2OjKXCf;r*1DWStin zlPA7F>@%;TZt&?+dC|{hvQ^oa>X%VBIx;9Hy+ST8FL-{b!iXf&46P!;lp;qY)0JwX zR3y4WSBATi4`#%bbY?#9`Pd3oDLy08ftoP&NStKfJ!ON9A%Y={vTrJfS|(BQGiezO zyYi&mT$(Tz85$i@djF|#ifj9np9{oGDsZ`qQldUgrTt2-RFtk83A-+d-O9H8EKg0} v)cSiW)YZlDZ{sV(6E|4R6AJO}8@dAcs`9;8mr~6kbk}pNS$!mSzL$RhFdoS* literal 0 HcmV?d00001 diff --git a/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/output.txt b/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/output.txt new file mode 100644 index 000000000000..f1479fdbf935 --- /dev/null +++ b/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/output.txt @@ -0,0 +1,70 @@ +Text: x y + text.getCharBoundaries(-5) = null + text.getCharBoundaries(-1) = null + text.getCharBoundaries(0) = null + text.getCharBoundaries(1) = null + text.getCharBoundaries(2) = null + text.getCharBoundaries(3) = null +Text: x y + text.getCharBoundaries(-5) = null + text.getCharBoundaries(-1) = null + text.getCharBoundaries(0) = null + text.getCharBoundaries(1) = null + text.getCharBoundaries(2) = null + text.getCharBoundaries(3) = null +Text: abcd ab + text.getCharBoundaries(-5) = null + text.getCharBoundaries(-1) = null + text.getCharBoundaries(0) = (x=2, y=2, w=9.6, h=12) + text.getCharBoundaries(1) = (x=11.6, y=2, w=9.6, h=12) + text.getCharBoundaries(2) = null + text.getCharBoundaries(3) = null + text.getCharBoundaries(4) = null + text.getCharBoundaries(5) = (x=21.2, y=2, w=9.6, h=12) + text.getCharBoundaries(6) = (x=30.8, y=2, w=9.6, h=12) + text.getCharBoundaries(7) = null +Text:

ab ab abababababa

+ text.getCharBoundaries(-5) = null + text.getCharBoundaries(-1) = null + text.getCharBoundaries(0) = (x=2, y=2, w=24, h=30) + text.getCharBoundaries(1) = (x=26, y=2, w=24, h=30) + text.getCharBoundaries(2) = null + text.getCharBoundaries(3) = (x=50, y=2, w=24, h=30) + text.getCharBoundaries(4) = (x=74, y=2, w=24, h=30) + text.getCharBoundaries(5) = null + text.getCharBoundaries(6) = (x=98, y=2, w=24, h=30) + text.getCharBoundaries(7) = (x=122, y=2, w=24, h=30) + text.getCharBoundaries(8) = (x=146, y=2, w=24, h=30) + text.getCharBoundaries(9) = (x=170, y=2, w=24, h=30) + text.getCharBoundaries(10) = (x=194, y=2, w=24, h=30) + text.getCharBoundaries(11) = (x=218, y=2, w=24, h=30) + text.getCharBoundaries(12) = (x=242, y=2, w=24, h=30) + text.getCharBoundaries(13) = (x=266, y=2, w=24, h=30) + text.getCharBoundaries(14) = (x=290, y=2, w=24, h=30) + text.getCharBoundaries(15) = (x=314, y=2, w=24, h=30) + text.getCharBoundaries(16) = (x=338, y=2, w=24, h=30) + text.getCharBoundaries(17) = null + text.getCharBoundaries(18) = null +Text:

ab ab abababababab

+ text.getCharBoundaries(-5) = null + text.getCharBoundaries(-1) = null + text.getCharBoundaries(0) = (x=2, y=2, w=24, h=30) + text.getCharBoundaries(1) = (x=26, y=2, w=24, h=30) + text.getCharBoundaries(2) = (x=50, y=2, w=280, h=30) + text.getCharBoundaries(3) = (x=330, y=2, w=24, h=30) + text.getCharBoundaries(4) = (x=354, y=2, w=24, h=30) + text.getCharBoundaries(5) = null + text.getCharBoundaries(6) = (x=2, y=32, w=24, h=30) + text.getCharBoundaries(7) = (x=26, y=32, w=24, h=30) + text.getCharBoundaries(8) = (x=50, y=32, w=24, h=30) + text.getCharBoundaries(9) = (x=74, y=32, w=24, h=30) + text.getCharBoundaries(10) = (x=98, y=32, w=24, h=30) + text.getCharBoundaries(11) = (x=122, y=32, w=24, h=30) + text.getCharBoundaries(12) = (x=146, y=32, w=24, h=30) + text.getCharBoundaries(13) = (x=170, y=32, w=24, h=30) + text.getCharBoundaries(14) = (x=194, y=32, w=24, h=30) + text.getCharBoundaries(15) = (x=218, y=32, w=24, h=30) + text.getCharBoundaries(16) = (x=242, y=32, w=24, h=30) + text.getCharBoundaries(17) = (x=266, y=32, w=24, h=30) + text.getCharBoundaries(18) = null + text.getCharBoundaries(19) = null diff --git a/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/test.swf b/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/test.swf new file mode 100644 index 0000000000000000000000000000000000000000..19af7c6f5f3de85d9cf4d57f99101681f645e6d2 GIT binary patch literal 2105 zcmV-92*&qAS5ql<4gdgn0j*YBZ`;Tfo*7<7k}r~PiXF!>6MN%aWRaE>ukF~X9V_Z) zizbUGX%?+jgBFJpHxwz5bS!Tl8U%eVu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V;H4=!^WG+O+TqKG(Z|BY>Ud`UO?ASY$Xv->y-P9+5uUs*0&-)hp%|t$NkGs#O=v z1+9A7yc`W*qq*qUn1dZMD0n@25n2K72FG>kV=AxU{jy`~ALe zJlm_dhhB~O5o4J%OiynzsGHCHy_V zDFBj$x2i<>8Z~e@8R0XJrYmlHo#GT8AsvsY_B zS`Wqi+Uly9FKBrx;h2z?(j)2QG+d4tql8c)79Yk`9Hmk!K8mR@23H9M3{iL_B*bxI zXdEXd;5~^&DK2AyM=~yBBEn5`HE_pJpad91X_V&`L9;){8L`1{9AhlWsqf{`gj<)x z1}{ifFA~Hn5$|zTu2Pd~Rmqg1fu~PH1nF*Qe8CNZH@tD3ekS#^CVBqr3C*69iW>Ln zo)7Wt;U{t|2e2K!*RI)z28&waN5PHyV!p8UU#~T{c3X}bkqAvF1~@_Y0hFaU#=H|r z6yWB~f+r9GxKRQR4UgcVQAm`yIG9HQfDI48*(>=N%T(@YfM^d-X}+UXg{o+ZJuHby zv?>fyJ&La5_2gf`&|so9+xz|G=wm8B`9!%fpc}FS_3(gb0Ne*u@OO j55q?`iE#oG3enUpCo>ZS&Uh{o;M9DMwt@H$GMF2s18?}w literal 0 HcmV?d00001 diff --git a/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/test.toml b/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/test.toml new file mode 100644 index 000000000000..cf6123969a1d --- /dev/null +++ b/tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/test.toml @@ -0,0 +1 @@ +num_ticks = 1