Skip to content

Commit

Permalink
tests: Add leading_define_font test
Browse files Browse the repository at this point in the history
This test verifies how FP renders text when the font has leading,
dependeing on different DefineFont tags used.
  • Loading branch information
kjarosh committed Oct 20, 2024
1 parent 245ce7f commit a0e448e
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 0 deletions.
118 changes: 118 additions & 0 deletions tests/tests/swfs/visual/fonts/leading_define_font/TestFont.sfd
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
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: -97
UnderlineWidth: 48
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: 1729444387
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 4

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

StartChar: b
Encoding: 98 98 1
Width: 100
Flags: HW
LayerCount: 2
Fore
SplineSet
0 800 m 1
100 800 l 1
100 0 l 1
0 0 l 1
0 800 l 1
EndSplineSet
EndChar

StartChar: c
Encoding: 99 99 2
Width: 800
Flags: HW
LayerCount: 2
Fore
SplineSet
0 0 m 1
800 0 l 1
800 -200 l 1
0 -200 l 1
0 0 l 1
EndSplineSet
EndChar

StartChar: d
Encoding: 100 100 3
Width: 100
Flags: HW
LayerCount: 2
Fore
SplineSet
0 0 m 1
100 0 l 1
100 -200 l 1
0 -200 l 1
0 0 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.
50 changes: 50 additions & 0 deletions tests/tests/swfs/visual/fonts/leading_define_font/test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
var nextX:int = 0;
var nextY:int = 0;
var i:int = 0;

function newTextField(font, leading) {
var text = _root.createTextField(
"text" + (i++),
_root.getNextHighestDepth(),
nextX, nextY, 50, 80);

text.border = true;
text.embedFonts = true;
var tf:TextFormat = new TextFormat();
tf.font = font;
tf.size = 20;
if (leading != null) {
tf.leading = leading;
}
text.setNewTextFormat(tf);

text.multiline = true;
text.text = "acbd\nabcd";

nextX += text._width + 2;
return text;
}

Stage.scaleMode = "noScale";

newTextField("TestFont2Gap0", null);
newTextField("TestFont2Gap0", 0);
newTextField("TestFont2Gap0", 2);
nextY += 100;
nextX = 0;
newTextField("TestFont2Gap100", null);
newTextField("TestFont2Gap100", 0);
newTextField("TestFont2Gap100", 2);
nextY += 100;
nextX = 0;

newTextField("TestFont3Gap0");
newTextField("TestFont3Gap0", 0);
newTextField("TestFont3Gap0", 2);
nextY += 100;
nextX = 0;
newTextField("TestFont3Gap100");
newTextField("TestFont3Gap100", 0);
newTextField("TestFont3Gap100", 2);
nextY += 100;
nextX = 0;
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/tests/swfs/visual/fonts/leading_define_font/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 a0e448e

Please sign in to comment.