diff --git a/core/src/html/layout.rs b/core/src/html/layout.rs
index bb6ddd4d5067..e0082225c752 100644
--- a/core/src/html/layout.rs
+++ b/core/src/html/layout.rs
@@ -660,10 +660,10 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
{
return font;
}
- // TODO: If set to use embedded fonts and we couldn't find any matching font, show nothing
- // However - at time of writing, we don't support DefineFont4. If we matched this behaviour,
- // then a bunch of SWFs would just show no text suddenly.
- // return new_empty_font(context, span, self.font_type);
+
+ // If set to use embedded fonts and we couldn't find any matching font, show nothing.
+ tracing::warn!("Embedded font not found: {font_name}, using an empty font");
+ return new_empty_font(context, span, self.font_type);
}
// Check if the font name is one of the known default fonts.
@@ -862,9 +862,9 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
fn left_alignment_offset(span: &TextSpan, is_first_line: bool) -> Twips {
if span.bullet {
if is_first_line {
- Twips::from_pixels(35.0 + span.left_margin + span.block_indent + span.indent)
+ Twips::from_pixels(36.0 + span.left_margin + span.block_indent + span.indent)
} else {
- Twips::from_pixels(35.0 + span.left_margin + span.block_indent)
+ Twips::from_pixels(36.0 + span.left_margin + span.block_indent)
}
} else {
Self::left_alignment_offset_without_bullet(span, is_first_line)
diff --git a/tests/tests/swfs/avm2/edittext_bullet_font/Test.as b/tests/tests/swfs/avm2/edittext_bullet_font/Test.as
new file mode 100644
index 000000000000..777837686ef7
--- /dev/null
+++ b/tests/tests/swfs/avm2/edittext_bullet_font/Test.as
@@ -0,0 +1,47 @@
+package {
+import flash.display.Sprite;
+import flash.text.TextField;
+import flash.text.TextFormat;
+
+[SWF(width="200", height="200")]
+public class Test extends Sprite {
+ [Embed(source="TestFontBulletA.ttf", fontName="TestFontNoBullet", embedAsCFF="false", unicodeRange="U+0061-U+0064")]
+ private var TestFontNoBullet:Class;
+
+ [Embed(source="TestFontBulletA.ttf", fontName="TestFontBulletA", embedAsCFF="false", unicodeRange="U+0061-U+0064,U+2022")]
+ private var TestFontBulletA:Class;
+
+ [Embed(source="TestFontBulletB.ttf", fontName="TestFontBulletB", embedAsCFF="false", unicodeRange="U+0061-U+0064,U+2022")]
+ private var TestFontBulletB:Class;
+
+ public function Test() {
+ stage.scaleMode = "noScale";
+
+ newTextField(5, 5, "TestFontBulletA", "
a");
+ newTextField(5, 55, "TestFontBulletA", "a");
+ newTextField(5, 105, "TestFontBulletA", "a");
+ newTextField(5, 155, "TestFontBulletA", "aa");
+ newTextField(105, 5, "TestFontBulletA", "aa");
+ newTextField(105, 55, "TestFontBulletA", "a");
+ newTextField(105, 105, "TestFontBulletA", "aa");
+ newTextField(105, 155, "TestFontBulletA", "aa");
+ }
+
+ private function newTextField(x: int, y: int, defaultFont: String, htmlText: String):void {
+ var text = new TextField();
+ text.border = true;
+ text.x = x;
+ text.y = y;
+ text.width = 90;
+ text.height = 40;
+ text.embedFonts = true;
+ var tf = new TextFormat();
+ tf.font = defaultFont;
+ tf.size = 20;
+ tf.leading = 5;
+ text.defaultTextFormat = tf;
+ text.htmlText = htmlText;
+ addChild(text);
+ }
+}
+}
diff --git a/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletA.sfd b/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletA.sfd
new file mode 100644
index 000000000000..de2cf270622e
--- /dev/null
+++ b/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletA.sfd
@@ -0,0 +1,134 @@
+SplineFontDB: 3.2
+FontName: TestFontBulletA
+FullName: TestFontBulletA
+FamilyName: TestFontBulletA
+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: 1732996340
+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: UnicodeBmp
+UnicodeInterp: none
+NameList: AGL For New Fonts
+DisplaySize: -48
+AntiAlias: 1
+FitToEm: 0
+WinInfo: 8190 30 10
+BeginPrivate: 0
+EndPrivate
+BeginChars: 65536 5
+
+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
+
+StartChar: b
+Encoding: 98 98 1
+Width: 108
+VWidth: 1083
+Flags: HW
+LayerCount: 2
+Fore
+SplineSet
+0 800 m 5
+ 108 800 l 5
+ 108 0 l 1
+ 0 0 l 1
+ 0 800 l 5
+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 5
+ 0 -200 l 5
+ 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 5
+ 0 -200 l 5
+ 0 0 l 1
+EndSplineSet
+EndChar
+
+StartChar: bullet
+Encoding: 8226 8226 4
+Width: 800
+Flags: HW
+LayerCount: 2
+Fore
+SplineSet
+100 700 m 1
+ 700 700 l 1
+ 700 100 l 5
+ 100 100 l 5
+ 100 700 l 1
+EndSplineSet
+EndChar
+EndChars
+EndSplineFont
diff --git a/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletA.ttf b/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletA.ttf
new file mode 100644
index 000000000000..1bfcf30314c9
Binary files /dev/null and b/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletA.ttf differ
diff --git a/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletB.sfd b/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletB.sfd
new file mode 100644
index 000000000000..58c8a5ae72c6
--- /dev/null
+++ b/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletB.sfd
@@ -0,0 +1,139 @@
+SplineFontDB: 3.2
+FontName: TestFontBulletB
+FullName: TestFontBulletB
+FamilyName: TestFontBulletB
+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: 1732996414
+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: UnicodeBmp
+UnicodeInterp: none
+NameList: AGL For New Fonts
+DisplaySize: -48
+AntiAlias: 1
+FitToEm: 0
+WinInfo: 8190 30 10
+BeginPrivate: 0
+EndPrivate
+BeginChars: 65536 5
+
+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
+Validated: 1
+EndChar
+
+StartChar: b
+Encoding: 98 98 1
+Width: 108
+VWidth: 1083
+Flags: HW
+LayerCount: 2
+Fore
+SplineSet
+0 800 m 5
+ 108 800 l 5
+ 108 0 l 1
+ 0 0 l 1
+ 0 800 l 5
+EndSplineSet
+Validated: 1
+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 5
+ 0 -200 l 5
+ 0 0 l 1
+EndSplineSet
+Validated: 1
+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 5
+ 0 -200 l 5
+ 0 0 l 1
+EndSplineSet
+Validated: 1
+EndChar
+
+StartChar: bullet
+Encoding: 8226 8226 4
+Width: 800
+Flags: HW
+LayerCount: 2
+Fore
+SplineSet
+300 500 m 1
+ 500 500 l 5
+ 500 300 l 5
+ 300 300 l 1
+ 300 500 l 1
+EndSplineSet
+Validated: 1
+EndChar
+EndChars
+EndSplineFont
diff --git a/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletB.ttf b/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletB.ttf
new file mode 100644
index 000000000000..c7b20dfe7caf
Binary files /dev/null and b/tests/tests/swfs/avm2/edittext_bullet_font/TestFontBulletB.ttf differ
diff --git a/tests/tests/swfs/avm2/edittext_bullet_font/output.expected.png b/tests/tests/swfs/avm2/edittext_bullet_font/output.expected.png
new file mode 100644
index 000000000000..e4b7f68b10f1
Binary files /dev/null and b/tests/tests/swfs/avm2/edittext_bullet_font/output.expected.png differ
diff --git a/tests/tests/swfs/avm2/edittext_bullet_font/output.txt b/tests/tests/swfs/avm2/edittext_bullet_font/output.txt
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/tests/tests/swfs/avm2/edittext_bullet_font/test.swf b/tests/tests/swfs/avm2/edittext_bullet_font/test.swf
new file mode 100644
index 000000000000..5a2dfe4737e9
Binary files /dev/null and b/tests/tests/swfs/avm2/edittext_bullet_font/test.swf differ
diff --git a/tests/tests/swfs/avm2/edittext_bullet_font/test.toml b/tests/tests/swfs/avm2/edittext_bullet_font/test.toml
new file mode 100644
index 000000000000..454b7bf7f4dc
--- /dev/null
+++ b/tests/tests/swfs/avm2/edittext_bullet_font/test.toml
@@ -0,0 +1,7 @@
+num_ticks = 1
+
+[image_comparisons.output]
+tolerance = 128
+
+[player_options]
+with_renderer = { optional = false, sample_count = 4 }
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 000000000000..080ba80b17cc
Binary files /dev/null and b/tests/tests/swfs/avm2/edittext_missing_font/test.swf differ
diff --git a/tests/tests/swfs/avm2/edittext_missing_font/test.toml b/tests/tests/swfs/avm2/edittext_missing_font/test.toml
new file mode 100644
index 000000000000..cf6123969a1d
--- /dev/null
+++ b/tests/tests/swfs/avm2/edittext_missing_font/test.toml
@@ -0,0 +1 @@
+num_ticks = 1
diff --git a/tests/tests/swfs/fonts/embed_matching/no_font_found/test.toml b/tests/tests/swfs/fonts/embed_matching/no_font_found/test.toml
index 79c486db198e..1d1205f06dc8 100644
--- a/tests/tests/swfs/fonts/embed_matching/no_font_found/test.toml
+++ b/tests/tests/swfs/fonts/embed_matching/no_font_found/test.toml
@@ -1,7 +1,6 @@
# There are no fonts embedded in this swf. It should not render anything at all, or error.
num_frames = 1
-known_failure = true # Right now we intentionally fall back, because we don't support DefineFont4 embedded fonts yet
[image_comparisons.output]
tolerance = 0
diff --git a/tests/tests/swfs/visual/fonts/font_lookup_as3/output.expected.png b/tests/tests/swfs/visual/fonts/font_lookup_as3/output.expected.png
index eb0809b9908e..0ffa47eb59e4 100644
Binary files a/tests/tests/swfs/visual/fonts/font_lookup_as3/output.expected.png and b/tests/tests/swfs/visual/fonts/font_lookup_as3/output.expected.png differ