Skip to content

Commit

Permalink
tests: Add avm2/edittext_getcharboundaries_missing_embedded_font test
Browse files Browse the repository at this point in the history
This test verifies how getCharBoundaries() works when glyphs are missing
due to embedded font not being present.
  • Loading branch information
kjarosh committed Dec 19, 2024
1 parent 402e943 commit 89c2faa
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;

[SWF(width="400", height="400")]
public class Test extends Sprite {
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>");
}

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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
num_ticks = 1

# Currently Ruffle falls back to device font on missing embedded font.
known_failure = true

0 comments on commit 89c2faa

Please sign in to comment.