Skip to content

Commit

Permalink
tests: Add avm2/edittext_missing_font test
Browse files Browse the repository at this point in the history
This test verifies how FP behaves when we want to get some metrics
related to text that uses a font which is missing.
  • Loading branch information
kjarosh committed Dec 8, 2024
1 parent 6c039e3 commit 335c174
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/tests/swfs/avm2/edittext_missing_font/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;

[SWF(width="200", height="200")]
public class Test extends Sprite {
private var nextY: int = 0;
private var nextX: int = 0;

public function Test() {
stage.scaleMode = "noScale";

newTextField(true, "input");
newTextField(true, "dynamic");
newTextField(false, "input");
newTextField(false, "dynamic");
}

private function newTextField(device: Boolean, type: String):void {
var text = new TextField();
text.type = type;
text.border = true;
text.x = nextX;
text.y = nextY;
nextY += 42;
text.width = 100;
text.height = 40;
text.embedFonts = !device;
var tf = new TextFormat();
tf.font = "Unknown Font 6ad5511bcd8b089c25e2212243c819d1";
tf.size = 20;
tf.leading = 5;
text.defaultTextFormat = tf;
text.text = "xyz";
addChild(text);

trace("device=" + device + ", type=" + type);
trace(" getTextFormat(0, 1).font=" + (text.getTextFormat(0, 1).font));
trace(" length=" + text.length);
trace(" text=" + text.text);
trace(" numLines=" + text.numLines);
trace(" textWidth is zero?=" + (text.textWidth == 0));
trace(" getCharBoundaries(0) is null?=" + (text.getCharBoundaries(0) == null));
trace(" getCharBoundaries(1) is null?=" + (text.getCharBoundaries(1) == null));
trace(" getCharBoundaries(3) is null?=" + (text.getCharBoundaries(3) == null));
trace(" getLineMetrics(0).ascent is zero?=" + (text.getLineMetrics(0).ascent == 0));
trace(" getLineMetrics(0).descent is zero?=" + (text.getLineMetrics(0).descent == 0));
trace(" getLineMetrics(0).height is 5?=" + (text.getLineMetrics(0).height == 5));
trace(" getLineMetrics(0).leading=" + (text.getLineMetrics(0).leading));
trace(" getLineMetrics(0).width is zero?=" + (text.getLineMetrics(0).width == 0));
}
}
}
56 changes: 56 additions & 0 deletions tests/tests/swfs/avm2/edittext_missing_font/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
device=true, type=input
getTextFormat(0, 1).font=Unknown Font 6ad5511bcd8b089c25e2212243c819d1
length=3
text=xyz
numLines=1
textWidth is zero?=false
getCharBoundaries(0) is null?=false
getCharBoundaries(1) is null?=false
getCharBoundaries(3) is null?=true
getLineMetrics(0).ascent is zero?=false
getLineMetrics(0).descent is zero?=false
getLineMetrics(0).height is 5?=false
getLineMetrics(0).leading=5
getLineMetrics(0).width is zero?=false
device=true, type=dynamic
getTextFormat(0, 1).font=Unknown Font 6ad5511bcd8b089c25e2212243c819d1
length=3
text=xyz
numLines=1
textWidth is zero?=false
getCharBoundaries(0) is null?=false
getCharBoundaries(1) is null?=false
getCharBoundaries(3) is null?=true
getLineMetrics(0).ascent is zero?=false
getLineMetrics(0).descent is zero?=false
getLineMetrics(0).height is 5?=false
getLineMetrics(0).leading=5
getLineMetrics(0).width is zero?=false
device=false, type=input
getTextFormat(0, 1).font=Unknown Font 6ad5511bcd8b089c25e2212243c819d1
length=3
text=xyz
numLines=1
textWidth is zero?=true
getCharBoundaries(0) is null?=true
getCharBoundaries(1) is null?=true
getCharBoundaries(3) is null?=true
getLineMetrics(0).ascent is zero?=true
getLineMetrics(0).descent is zero?=true
getLineMetrics(0).height is 5?=true
getLineMetrics(0).leading=5
getLineMetrics(0).width is zero?=true
device=false, type=dynamic
getTextFormat(0, 1).font=Unknown Font 6ad5511bcd8b089c25e2212243c819d1
length=3
text=xyz
numLines=1
textWidth is zero?=true
getCharBoundaries(0) is null?=true
getCharBoundaries(1) is null?=true
getCharBoundaries(3) is null?=true
getLineMetrics(0).ascent is zero?=true
getLineMetrics(0).descent is zero?=true
getLineMetrics(0).height is 5?=true
getLineMetrics(0).leading=5
getLineMetrics(0).width is zero?=true
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm2/edittext_missing_font/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit 335c174

Please sign in to comment.