-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add avm2/edittext_getcharboundaries_missing_glyphs test
This test verifies how getCharBoundaries() work when glyphs are missing.
- Loading branch information
Showing
5 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/Test.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("<font face='Unknown Font'>x y</font>"); | ||
testHtml("<font face='TestFont'>x y</font>"); | ||
testHtml("<font face='TestFont'>abcd ab</font>"); | ||
|
||
text.wordWrap = true; | ||
testHtml("<p align='justify'><font size='30' face='TestFont'>ab ab abababababa</font></p>"); | ||
testHtml("<p align='justify'><font size='30' face='TestFont'>ab ab abababababab</font></p>"); | ||
} | ||
|
||
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); | ||
} | ||
} | ||
} |
Binary file added
BIN
+1.56 KB
tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/TestFont.ttf
Binary file not shown.
70 changes: 70 additions & 0 deletions
70
tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
Text: <font face='Unknown Font'>x y</font> | ||
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: <font face='TestFont'>x y</font> | ||
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: <font face='TestFont'>abcd ab</font> | ||
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: <p align='justify'><font size='30' face='TestFont'>ab ab abababababa</font></p> | ||
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: <p align='justify'><font size='30' face='TestFont'>ab ab abababababab</font></p> | ||
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 |
Binary file added
BIN
+2.06 KB
tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/test.swf
Binary file not shown.
1 change: 1 addition & 0 deletions
1
tests/tests/swfs/avm2/edittext_getcharboundaries_missing_glyphs/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
num_ticks = 1 |