Skip to content

Commit 413aab6

Browse files
committed
tests: Add avm2/edittext_missing_font test
This test verifies how FP behaves when we want to get some metrics related to text that uses a font which is missing.
1 parent 854b9cb commit 413aab6

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package {
2+
import flash.display.Sprite;
3+
import flash.text.TextField;
4+
import flash.text.TextFormat;
5+
6+
[SWF(width="200", height="200")]
7+
public class Test extends Sprite {
8+
private var nextY: int = 0;
9+
private var nextX: int = 0;
10+
11+
public function Test() {
12+
stage.scaleMode = "noScale";
13+
14+
newTextField(true, "input");
15+
newTextField(true, "dynamic");
16+
newTextField(false, "input");
17+
newTextField(false, "dynamic");
18+
}
19+
20+
private function newTextField(device: Boolean, type: String):void {
21+
var text = new TextField();
22+
text.type = type;
23+
text.border = true;
24+
text.x = nextX;
25+
text.y = nextY;
26+
nextY += 42;
27+
text.width = 100;
28+
text.height = 40;
29+
text.embedFonts = !device;
30+
var tf = new TextFormat();
31+
tf.font = "Unknown Font 6ad5511bcd8b089c25e2212243c819d1";
32+
tf.size = 20;
33+
tf.leading = 5;
34+
text.defaultTextFormat = tf;
35+
text.text = "xyz";
36+
addChild(text);
37+
38+
trace("device=" + device + ", type=" + type);
39+
trace(" getTextFormat(0, 1).font=" + (text.getTextFormat(0, 1).font));
40+
trace(" length=" + text.length);
41+
trace(" text=" + text.text);
42+
trace(" numLines=" + text.numLines);
43+
trace(" textWidth is zero?=" + (text.textWidth == 0));
44+
trace(" getCharBoundaries(0) is null?=" + (text.getCharBoundaries(0) == null));
45+
trace(" getCharBoundaries(1) is null?=" + (text.getCharBoundaries(1) == null));
46+
trace(" getCharBoundaries(3) is null?=" + (text.getCharBoundaries(3) == null));
47+
trace(" getLineMetrics(0).ascent is zero?=" + (text.getLineMetrics(0).ascent == 0));
48+
trace(" getLineMetrics(0).descent is zero?=" + (text.getLineMetrics(0).descent == 0));
49+
trace(" getLineMetrics(0).height is 5?=" + (text.getLineMetrics(0).height == 5));
50+
trace(" getLineMetrics(0).leading=" + (text.getLineMetrics(0).leading));
51+
trace(" getLineMetrics(0).width is zero?=" + (text.getLineMetrics(0).width == 0));
52+
}
53+
}
54+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
device=true, type=input
2+
getTextFormat(0, 1).font=Unknown Font 6ad5511bcd8b089c25e2212243c819d1
3+
length=3
4+
text=xyz
5+
numLines=1
6+
textWidth is zero?=false
7+
getCharBoundaries(0) is null?=false
8+
getCharBoundaries(1) is null?=false
9+
getCharBoundaries(3) is null?=true
10+
getLineMetrics(0).ascent is zero?=false
11+
getLineMetrics(0).descent is zero?=false
12+
getLineMetrics(0).height is 5?=false
13+
getLineMetrics(0).leading=5
14+
getLineMetrics(0).width is zero?=false
15+
device=true, type=dynamic
16+
getTextFormat(0, 1).font=Unknown Font 6ad5511bcd8b089c25e2212243c819d1
17+
length=3
18+
text=xyz
19+
numLines=1
20+
textWidth is zero?=false
21+
getCharBoundaries(0) is null?=false
22+
getCharBoundaries(1) is null?=false
23+
getCharBoundaries(3) is null?=true
24+
getLineMetrics(0).ascent is zero?=false
25+
getLineMetrics(0).descent is zero?=false
26+
getLineMetrics(0).height is 5?=false
27+
getLineMetrics(0).leading=5
28+
getLineMetrics(0).width is zero?=false
29+
device=false, type=input
30+
getTextFormat(0, 1).font=Unknown Font 6ad5511bcd8b089c25e2212243c819d1
31+
length=3
32+
text=xyz
33+
numLines=1
34+
textWidth is zero?=true
35+
getCharBoundaries(0) is null?=true
36+
getCharBoundaries(1) is null?=true
37+
getCharBoundaries(3) is null?=true
38+
getLineMetrics(0).ascent is zero?=true
39+
getLineMetrics(0).descent is zero?=true
40+
getLineMetrics(0).height is 5?=true
41+
getLineMetrics(0).leading=5
42+
getLineMetrics(0).width is zero?=true
43+
device=false, type=dynamic
44+
getTextFormat(0, 1).font=Unknown Font 6ad5511bcd8b089c25e2212243c819d1
45+
length=3
46+
text=xyz
47+
numLines=1
48+
textWidth is zero?=true
49+
getCharBoundaries(0) is null?=true
50+
getCharBoundaries(1) is null?=true
51+
getCharBoundaries(3) is null?=true
52+
getLineMetrics(0).ascent is zero?=true
53+
getLineMetrics(0).descent is zero?=true
54+
getLineMetrics(0).height is 5?=true
55+
getLineMetrics(0).leading=5
56+
getLineMetrics(0).width is zero?=true
1.57 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
num_ticks = 1

0 commit comments

Comments
 (0)