Skip to content

Commit 0a80884

Browse files
committed
tests: Add visual/edittext/edittext_device_transform_metrics test
1 parent c6baf30 commit 0a80884

File tree

5 files changed

+129
-0
lines changed

5 files changed

+129
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package {
2+
import flash.display.*;
3+
import flash.text.*;
4+
import flash.geom.*;
5+
6+
[SWF(width="200", height="200")]
7+
public class Test extends Sprite {
8+
[Embed(source="TestFont.ttf", fontName="TestFont", embedAsCFF="false", unicodeRange="U+0061-U+0064")]
9+
private var TestFont:Class;
10+
11+
private var nextX:int = 0;
12+
private var nextY:int = 0;
13+
14+
public function Test() {
15+
stage.scaleMode = "noScale";
16+
17+
test(false);
18+
test(false, 2);
19+
test(false, 1, 2);
20+
test(false, 2, 2);
21+
22+
nextX = 100;
23+
nextY = 0;
24+
25+
test(true);
26+
test(true, 2);
27+
test(true, 1, 2);
28+
test(true, 2, 2);
29+
}
30+
31+
private function test(device: Boolean, scaleX: Number = 1, scaleY: Number = 1):TextField {
32+
var text:TextField = new TextField();
33+
text.x = nextX;
34+
text.y = nextY;
35+
text.border = true;
36+
text.width = 40;
37+
text.height = 20;
38+
text.embedFonts = !device;
39+
var tf:TextFormat = new TextFormat();
40+
tf.font = "TestFont";
41+
tf.size = 10;
42+
text.defaultTextFormat = tf;
43+
44+
text.multiline = true;
45+
text.text = "ab\n\n\n\n\n\n\n\n\n\n\nab";
46+
text.scaleX = scaleX;
47+
text.scaleY = scaleY;
48+
addChild(text);
49+
50+
nextY += 50;
51+
52+
trace("" + device + " = " + text.getCharBoundaries(0) + "," + text.getCharBoundaries(1));
53+
trace("" + device + " = " +
54+
text.getCharIndexAtPoint(1, 5) + "," +
55+
text.getCharIndexAtPoint(2, 5) + "," +
56+
text.getCharIndexAtPoint(5, 5) + "," +
57+
text.getCharIndexAtPoint(8, 5) + "," +
58+
text.getCharIndexAtPoint(10, 5) + "," +
59+
text.getCharIndexAtPoint(12, 5) + "," +
60+
text.getCharIndexAtPoint(15, 5) + "," +
61+
text.getCharIndexAtPoint(8, 1) + "," +
62+
text.getCharIndexAtPoint(12, 1) + "," +
63+
text.getCharIndexAtPoint(8, 12) + "," +
64+
text.getCharIndexAtPoint(12, 12) + "," +
65+
"");
66+
trace("" + device + " = " + metricsToString(text.getLineMetrics(0)));
67+
trace("" + device + " = " + text.textHeight);
68+
trace("" + device + " = " + text.textWidth);
69+
70+
return text;
71+
}
72+
73+
private function metricsToString(m:TextLineMetrics): String {
74+
return "height=" + Math.round(m.height) +
75+
",width=" + Math.round(m.width) +
76+
",x=" + Math.round(m.x) +
77+
",ascent=" + Math.round(m.ascent) +
78+
",descent=" + Math.round(m.descent);
79+
}
80+
}
81+
}
Binary file not shown.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
2+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
3+
false = height=10,width=16,x=2,ascent=8,descent=2
4+
false = 120
5+
false = 16
6+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
7+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
8+
false = height=10,width=16,x=2,ascent=8,descent=2
9+
false = 120
10+
false = 16
11+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
12+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
13+
false = height=10,width=16,x=2,ascent=8,descent=2
14+
false = 120
15+
false = 16
16+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
17+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
18+
false = height=10,width=16,x=2,ascent=8,descent=2
19+
false = 120
20+
false = 16
21+
true = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
22+
true = 0,0,0,0,1,1,1,-1,-1,-1,-1,
23+
true = height=10,width=16,x=102,ascent=8,descent=2
24+
true = 120
25+
true = 16
26+
true = (x=2, y=2, w=4, h=10),(x=6, y=2, w=4, h=10)
27+
true = 0,0,0,1,-1,-1,-1,-1,-1,-1,-1,
28+
true = height=5,width=8,x=52,ascent=4,descent=1
29+
true = 60
30+
true = 8
31+
true = (x=2, y=2, w=16, h=10),(x=18, y=2, w=16, h=10)
32+
true = 0,0,0,0,0,0,0,-1,-1,-1,-1,
33+
true = height=20,width=32,x=102,ascent=16,descent=4
34+
true = 240
35+
true = 32
36+
true = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
37+
true = 0,0,0,0,1,1,1,-1,-1,-1,-1,
38+
true = height=10,width=16,x=52,ascent=8,descent=2
39+
true = 120
40+
true = 16
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
num_ticks = 1
2+
known_failure = true
3+
4+
[fonts.test_font]
5+
family = "TestFont"
6+
path = "TestFont.ttf"
7+
bold = false
8+
italic = false

0 commit comments

Comments
 (0)