Skip to content

Commit

Permalink
tests: Add edittext_gutter test
Browse files Browse the repository at this point in the history
This test verifies how the gutter of a text field behaves.
  • Loading branch information
kjarosh committed Oct 14, 2024
1 parent 61f5c1b commit a42eab9
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 0 deletions.
76 changes: 76 additions & 0 deletions tests/tests/swfs/visual/edittext/edittext_gutter/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;

[SWF(width="100", height="110")]
public class Test extends Sprite {
[Embed(source="TestFont.ttf", fontName="TestFont", embedAsCFF="false", unicodeRange="U+0061-U+0062")]
private var testFont:Class;

private var nextX:int = 2;
private var nextY:int = 2;

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

newTextField("a", 0, 0);
newTextField("a", 1, 0);
newTextField("a", 2, 0);
newTextField("a", 3, 0);
newTextField("a", 4, 0);
newTextField("a", 5, 0);
newTextField("a", 6, 0);
newTextField("a", 7, 0);
newTextField("a", 8, 0);
newTextField("a", 40, 0);
nextY += 34;
nextX = 2;

newTextField("b", 0, 0);
newTextField("b", 1, 0);
newTextField("b", 2, 0);
newTextField("b", 3, 0);
newTextField("b", 4, 0);
newTextField("b", 5, 0);
newTextField("b", 6, 0);
newTextField("b", 7, 0);
newTextField("b", 8, 0);
newTextField("b", 40, 0);
nextY += 34;
nextX = 2;

newTextField("b", 6, 0);
newTextField("b", 6, 1);
newTextField("b", 6, 2);
newTextField("b", 6, 3);
newTextField("b", 6, 4);
newTextField("b", 6, 5);
newTextField("b", 6, 6);
newTextField("b", 6, 18);
newTextField("b", 6, 19);
newTextField("b", 6, 20);
newTextField("b", 6, 21);
newTextField("b", 6, 22);
}

private function newTextField(value: String, width: int, hscroll: int): void {
var text:TextField = new TextField();
text.border = true;
text.width = width;
text.x = nextX;
text.y = nextY;
text.height = 30;
text.embedFonts = true;
var tf = new TextFormat();
tf.font = "TestFont";
tf.size = 20;
text.defaultTextFormat = tf;
text.text = value;
text.scrollH = hscroll;
nextX += text.width + 2;
addChild(text);
}

}
}
83 changes: 83 additions & 0 deletions tests/tests/swfs/visual/edittext/edittext_gutter/TestFont.sfd
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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: -100
UnderlineWidth: 50
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: 1728902792
OS2TypoAscent: 0
OS2TypoAOffset: 1
OS2TypoDescent: 0
OS2TypoDOffset: 1
OS2TypoLinegap: 90
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 2

StartChar: a
Encoding: 97 97 0
Width: 50
Flags: HW
LayerCount: 2
Fore
SplineSet
0 800 m 1
50 800 l 1
50 0 l 1
0 0 l 1
0 800 l 1
EndSplineSet
EndChar

StartChar: b
Encoding: 98 98 1
Width: 1000
Flags: HW
LayerCount: 2
Fore
SplineSet
0 800 m 1
1000 800 l 1
1000 0 l 1
0 0 l 1
0 800 l 1
EndSplineSet
EndChar
EndChars
EndSplineFont
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/tests/swfs/visual/edittext/edittext_gutter/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
num_ticks = 1

[image_comparisons.output]
tolerance = 128

[player_options]
with_renderer = { optional = false, sample_count = 4 }

0 comments on commit a42eab9

Please sign in to comment.