From c36a013bec71b4087bebfad299cafb3fe8e1fc5e Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Mon, 13 Jan 2025 00:20:36 +0100 Subject: [PATCH] tests: Add avm2/font_enumeratefonts_order test This test verifies the order which fonts are enumerated in. --- .../avm2/font_enumeratefonts_order/FontSwf.as | 10 +++ .../avm2/font_enumeratefonts_order/Test.as | 48 ++++++++++++ .../font_enumeratefonts_order/TestFont.sfd | 73 ++++++++++++++++++ .../font_enumeratefonts_order/TestFont.ttf | Bin 0 -> 1572 bytes .../avm2/font_enumeratefonts_order/font.swf | Bin 0 -> 1373 bytes .../avm2/font_enumeratefonts_order/output.txt | 9 +++ .../avm2/font_enumeratefonts_order/test.swf | Bin 0 -> 2326 bytes .../avm2/font_enumeratefonts_order/test.toml | 1 + 8 files changed, 141 insertions(+) create mode 100644 tests/tests/swfs/avm2/font_enumeratefonts_order/FontSwf.as create mode 100644 tests/tests/swfs/avm2/font_enumeratefonts_order/Test.as create mode 100644 tests/tests/swfs/avm2/font_enumeratefonts_order/TestFont.sfd create mode 100644 tests/tests/swfs/avm2/font_enumeratefonts_order/TestFont.ttf create mode 100644 tests/tests/swfs/avm2/font_enumeratefonts_order/font.swf create mode 100644 tests/tests/swfs/avm2/font_enumeratefonts_order/output.txt create mode 100644 tests/tests/swfs/avm2/font_enumeratefonts_order/test.swf create mode 100644 tests/tests/swfs/avm2/font_enumeratefonts_order/test.toml diff --git a/tests/tests/swfs/avm2/font_enumeratefonts_order/FontSwf.as b/tests/tests/swfs/avm2/font_enumeratefonts_order/FontSwf.as new file mode 100644 index 000000000000..62652c50e3ae --- /dev/null +++ b/tests/tests/swfs/avm2/font_enumeratefonts_order/FontSwf.as @@ -0,0 +1,10 @@ +package { +import flash.display.*; +import flash.text.*; + +public class FontSwf extends Sprite { + [Embed(source="TestFont.ttf", fontName="TestFont4", embedAsCFF="false", unicodeRange="U+0061-U+0061")] + private var TestFont4:Class; +} + +} diff --git a/tests/tests/swfs/avm2/font_enumeratefonts_order/Test.as b/tests/tests/swfs/avm2/font_enumeratefonts_order/Test.as new file mode 100644 index 000000000000..094c4853acff --- /dev/null +++ b/tests/tests/swfs/avm2/font_enumeratefonts_order/Test.as @@ -0,0 +1,48 @@ +package { +import flash.display.*; +import flash.text.*; +import flash.net.*; +import flash.system.*; +import flash.events.*; + +public class Test extends Sprite { + [Embed(source="TestFont.ttf", fontName="TestFont1", embedAsCFF="false", unicodeRange="U+0061-U+0061")] + private var TestFont1:Class; + + [Embed(source="TestFont.ttf", fontName="Test Font3", embedAsCFF="false", unicodeRange="U+0061-U+0061")] + private var TestFont2:Class; + + [Embed(source="TestFont.ttf", fontName="TestFont2", embedAsCFF="false", unicodeRange="U+0061-U+0061")] + private var TestFont3:Class; + + [Embed(source="TestFont.ttf", fontName="TestFont7", embedAsCFF="false", unicodeRange="U+0061-U+0061")] + private var TestFont4:Class; + + [Embed(source="TestFont.ttf", fontName="TeStfONt6", embedAsCFF="false", unicodeRange="U+0061-U+0061")] + private var TestFont5:Class; + + [Embed(source="TestFont.ttf", fontName="testfont5", embedAsCFF="false", unicodeRange="U+0061-U+0061")] + private var TestFont6:Class; + + public function Test() { + Font.registerFont(TestFont2); + Font.registerFont(TestFont1); + + var fontLoader:Loader = new Loader(); + var context:LoaderContext = new LoaderContext(); + context.allowCodeImport = true; + fontLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onFontLoaded); + fontLoader.load(new URLRequest("font.swf"), context); + } + + private function onFontLoaded(event:Event):void { + var fontClass:Class = event.target.applicationDomain.getDefinition("FontSwf_TestFont4") as Class; + Font.registerFont(fontClass); + + for each (var font: Font in Font.enumerateFonts()) { + trace(font.fontName + ", " + font.fontStyle + ", " + font.fontType); + } + } +} + +} diff --git a/tests/tests/swfs/avm2/font_enumeratefonts_order/TestFont.sfd b/tests/tests/swfs/avm2/font_enumeratefonts_order/TestFont.sfd new file mode 100644 index 000000000000..8d2b69f21714 --- /dev/null +++ b/tests/tests/swfs/avm2/font_enumeratefonts_order/TestFont.sfd @@ -0,0 +1,73 @@ +SplineFontDB: 3.2 +FontName: TestFont +FullName: TestFont +FamilyName: TestFont +Weight: Regular +Copyright: Copyright (c) 2024, Kamil Jarosz +UComments: "2024-7-24: Created with FontForge (http://fontforge.org)" +Version: 001.000 +ItalicAngle: 0 +UnderlinePosition: -76 +UnderlineWidth: 38 +Ascent: 800 +Descent: 200 +InvalidEm: 0 +LayerCount: 2 +Layer: 0 0 "Back" 1 +Layer: 1 0 "Fore" 0 +XUID: [1021 253 198287149 6396829] +StyleMap: 0x0000 +FSType: 0 +OS2Version: 0 +OS2_WeightWidthSlopeOnly: 0 +OS2_UseTypoMetrics: 1 +CreationTime: 1721856925 +ModificationTime: 1736720091 +PfmFamily: 17 +TTFWeight: 400 +TTFWidth: 5 +LineGap: 100 +VLineGap: 0 +OS2TypoAscent: 0 +OS2TypoAOffset: 1 +OS2TypoDescent: 0 +OS2TypoDOffset: 1 +OS2TypoLinegap: 100 +OS2WinAscent: 0 +OS2WinAOffset: 1 +OS2WinDescent: 0 +OS2WinDOffset: 1 +HheadAscent: 0 +HheadAOffset: 1 +HheadDescent: 0 +HheadDOffset: 1 +OS2Vendor: 'PfEd' +MarkAttachClasses: 1 +DEI: 91125 +Encoding: ISO8859-1 +UnicodeInterp: none +NameList: AGL For New Fonts +DisplaySize: -48 +AntiAlias: 1 +FitToEm: 0 +WinInfo: 0 30 10 +BeginPrivate: 0 +EndPrivate +BeginChars: 256 1 + +StartChar: a +Encoding: 97 97 0 +Width: 800 +Flags: HW +LayerCount: 2 +Fore +SplineSet +0 800 m 5 + 800 800 l 5 + 800 0 l 1 + 0 0 l 1 + 0 800 l 5 +EndSplineSet +EndChar +EndChars +EndSplineFont diff --git a/tests/tests/swfs/avm2/font_enumeratefonts_order/TestFont.ttf b/tests/tests/swfs/avm2/font_enumeratefonts_order/TestFont.ttf new file mode 100644 index 0000000000000000000000000000000000000000..56e988706857d05f312f5a3cf10f274116086b8d GIT binary patch literal 1572 zcmd5+O-NKx6#nk}8MVZpC?c@9Lslv}&X0x3EX1Ellt@f1XpzrxoEeyLhBsqqP_&MS zRxPAe5#grNO%blzSc~>83d|y0B(2&R(|7MYMP0OM(|w$KzjN+6=YH?p^Bx3%8r*@2 ziCAp(;$qu}dB9gmYr}=U{uqwnFkt^s`lZY5;j!;i5kRDH23 z-(bAizIbsUTpj~B&;0@Fa>mIfs$ac-!u>~paV(!J6mba6 zJpVQKTcF;R((>i=*!9}zFB~*CXu)dZ{G>;tjEKGeKzZ1 zgG}yw*hC}NJj`AcM?Gw#R&;yVNBgAe1WWZ>H>HdP>Jay^!9T)n51ahL9(ve9ov=M@ z*$P8DECJMz^ZiZ-tTS-QH+H-)qn literal 0 HcmV?d00001 diff --git a/tests/tests/swfs/avm2/font_enumeratefonts_order/font.swf b/tests/tests/swfs/avm2/font_enumeratefonts_order/font.swf new file mode 100644 index 0000000000000000000000000000000000000000..20b1201f2639f1a84e3e70d87d8100b90c9f4f2b GIT binary patch literal 1373 zcmV-j1)};xS5qk@3IG6j0j*TaZW~n?KIhEk_>$O8lbS%OFzO;)V$awPZgZ)XC~i=S z)S$YB3dLBH@tJtYc*dF;*Df12JOa|}9;~Co}q6n!Y z&F#OPbH4xoz7dlDL@4t;LaP`xmR1o$-z-1H2<`YCYwK>~pfKt=Zm(MDK$S4^iTkK0@%*XM({@}#1 zgD&&qb()?P4h{KMq0(qM0Gb8l=Gbs+^DURWu4vbS)XKwp`Q`DTA#0iX$ z)o&Yape&%Yei&%?$%KzH+b{TQSsBgX7lr-yA3qX!U(){HF8g- z9kfqgym;|NN&=S(x12lsr3zz$(39VPG`@qcC#eI^4Vyy?J->v}w zQ@CyTUhp+~yz&Dq%l8m3oI@q}Lo0M@&|qS=x1-;Z5iCWY?Rc4uIT7P%c#CZS7*ZpeJY4DE+(V#&Yc-v=NK+hsnfZK?{+lYDv==d&nH ziA=FV38e&6X@QbOs${5?qtX(UEkZ0K^2#4Gb3e z#fhXe);|Vh34||?^=HyK9k;N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;7oPtTM2Vhydis zkD*-Qo<8_k6v*5_ZhcDvEMNentyGS&Oy#-?sJ1Yb#_MWM$cd)d!jqUp&B24`Bp#BN zL*I#L>KsH>5BAPr0(c~FKlU_uV?+`r?(Zo53Ce9$5@FJRchv<2T zYUd!Tok3LdBC7pxh$b$`ql^Csc{F|wqVY3`#=VHfe>g)8_td#{*@oT?wej!iqF4$Tq!4Mu!yfeD3Pr`ha& wFlYgrf`GSE0WA+91r33Rkc9t;dI$;V&^!bU{>SPe#K99Ipa-z{4+2q0ZX_y%?f?J) literal 0 HcmV?d00001 diff --git a/tests/tests/swfs/avm2/font_enumeratefonts_order/test.toml b/tests/tests/swfs/avm2/font_enumeratefonts_order/test.toml new file mode 100644 index 000000000000..99142b5c1359 --- /dev/null +++ b/tests/tests/swfs/avm2/font_enumeratefonts_order/test.toml @@ -0,0 +1 @@ +num_ticks = 3