From 765ff8fd35edf3863c57313c5d8924930c98a617 Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Sat, 30 Nov 2024 19:54:22 +0100 Subject: [PATCH] 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. --- .../swfs/avm2/edittext_missing_font/Test.as | 54 +++++++++++++++++ .../avm2/edittext_missing_font/output.txt | 56 ++++++++++++++++++ .../swfs/avm2/edittext_missing_font/test.swf | Bin 0 -> 1609 bytes .../swfs/avm2/edittext_missing_font/test.toml | 1 + 4 files changed, 111 insertions(+) create mode 100644 tests/tests/swfs/avm2/edittext_missing_font/Test.as create mode 100644 tests/tests/swfs/avm2/edittext_missing_font/output.txt create mode 100644 tests/tests/swfs/avm2/edittext_missing_font/test.swf create mode 100644 tests/tests/swfs/avm2/edittext_missing_font/test.toml diff --git a/tests/tests/swfs/avm2/edittext_missing_font/Test.as b/tests/tests/swfs/avm2/edittext_missing_font/Test.as new file mode 100644 index 000000000000..ad615072927d --- /dev/null +++ b/tests/tests/swfs/avm2/edittext_missing_font/Test.as @@ -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)); + } +} +} diff --git a/tests/tests/swfs/avm2/edittext_missing_font/output.txt b/tests/tests/swfs/avm2/edittext_missing_font/output.txt new file mode 100644 index 000000000000..80b1571cb785 --- /dev/null +++ b/tests/tests/swfs/avm2/edittext_missing_font/output.txt @@ -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 diff --git a/tests/tests/swfs/avm2/edittext_missing_font/test.swf b/tests/tests/swfs/avm2/edittext_missing_font/test.swf new file mode 100644 index 0000000000000000000000000000000000000000..080ba80b17ccc6eab0ee8143e824a8cd1be39e7d GIT binary patch literal 1609 zcmV-P2DbS_S5qlh3IG6j0fkk~a@$4{o&i8YpeRbR{;5AmqD9H!4+u(*B#W|SDNO9d zc4FFbvQ;eA5EzhHLjVf^MahRGl~>rRJ?p*?v8NpN#)OA`g;Xv^p1^4Uv_vMV3aT(O z{dIpmJ?QR111%pSzJt&#MknL52%+yMe#Hpw+p4zr;-oBIoEfIG2U02BaNXu!KHqM) zbM0czvg`T6?(S}0lJl~h1&ge6X}aVhYdUM`gTTQFbrf4~y1HeGzC%*8T5c(w?s-*} zYp2bYZ3He=B~J}{Morhr7jgw~q$+!wWuFoEfHa$it`Of{{vzu%Eagp`oYSmk5T~)9 zzcKVVuI?K2;HXKI1{KQ&y%3LX=z(!);oGV=aUS$esR1KL0(KBr!05O0dCgYM(47Xg zKkQSnG`CG`*wAX3Y7l8ayfO4?icN`Y{VnN(nNKl@S#Oa#J)q|4t4iSW8VXK8Tzc@# zIv0ylMwBIaD~#7i_w)Xz?@L7wf$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