Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
337 changes: 268 additions & 69 deletions core/src/font.rs

Large diffs are not rendered by default.

50 changes: 30 additions & 20 deletions core/src/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::font::{DefaultFont, EvalParameters, Font, FontLike, FontSet, FontType};
use crate::html::dimensions::{BoxBounds, Position, Size};
use crate::html::text_format::{FormatSpans, TextFormat, TextSpan};
use crate::string::{WStr, utils as string_utils};
use crate::string::WStr;
use crate::tag_utils::SwfMovie;
use gc_arena::Collect;
use std::cmp::{Ordering, max, min};
Expand Down Expand Up @@ -177,26 +177,36 @@
if self.is_word_wrap {
let (mut width, mut offset) = self.wrap_dimensions(span);

while let Some(breakpoint) = font_set.wrap_line(
&text[last_breakpoint..],
params,
width,
offset,
self.is_start_of_line(),
) {
// This ensures that the space causing the line break
// is included in the line it broke.
let next_breakpoint =
string_utils::next_char_boundary(text, last_breakpoint + breakpoint);

// If text doesn't fit at the start of a line, it
// won't fit on the next either, abort and put the
// whole text on the line (will be cut-off). This
// can happen for small text fields with single
// characters.
if breakpoint == 0 && self.is_start_of_line() {
loop {
let breakpoint = if self.movie.version() >= 8 {
font_set.wrap_line_swf8(
&text[last_breakpoint..],
params,
width,
offset,
self.is_start_of_line(),
)
} else {
font_set.wrap_line_swf7(
&text[last_breakpoint..],
params,
width,
offset,
self.is_start_of_line(),
)
};
let Some(breakpoint) = breakpoint else {
break;
} else if breakpoint == 0 {
};

let next_breakpoint = last_breakpoint + breakpoint;

if breakpoint == 0 {
if self.is_start_of_line() {
unreachable!(

Check warning on line 206 in core/src/html/layout.rs

View workflow job for this annotation

GitHub Actions / Coverage Report

Coverage

Uncovered line (206)
"wrap_line is supposed to return nonzero if is_start_of_line"
);
}
self.newline(context, start + next_breakpoint, span, false);

let next_dim = self.wrap_dimensions(span);
Expand Down
Binary file modified tests/tests/swfs/avm1/edittext_tag_indent/output.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 25 additions & 5 deletions tests/tests/swfs/avm1/edittext_tag_indent/output.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Indent for _level0.text1:
Indent for text1:
1638
1638
Indent for _level0.text2:
Indent for text2:
-1638
-1638
Indent for _level0.text3:
Indent for text3:
-10
-10
Indent for _level0.text4:
Indent for text4:
2
2
Indent for _level0.text5:
Indent for text5:
-4
-4
Setting 0 -> 0
Expand All @@ -29,3 +29,23 @@ Setting 2 -> 2
Setting -10 -> -10
Setting 100 -> 100
Setting 64010 -> 64010
lines for text1:
a
bcdabcd

lines for text2:
abcdabcd


lines for text3:
abcdabcd


lines for text4:
abcdabcd


lines for text5:
abcdabcd


Binary file modified tests/tests/swfs/avm1/edittext_tag_indent/test.swf
Binary file not shown.
43 changes: 0 additions & 43 deletions tests/tests/swfs/avm2/edittext_wrap_breaks/output.ruffle.txt

This file was deleted.

1 change: 0 additions & 1 deletion tests/tests/swfs/avm2/edittext_wrap_breaks/test.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ PASSED: tf._width > 10 [./TextField.as:965]
PASSED: tf.textWidth == origTextWidth [./TextField.as:966]
After setting wordWrap flat: textWidth: 63 origTextWidth:63
PASSED: tf.textWidth == origTextWidth [./TextField.as:970]
After reducing _width: textWidth: 63 origTextWidth:63
After reducing _width: textWidth: 9 origTextWidth:63
PASSED: tf._width == 10 [./TextField.as:973]
FAILED: origTextWidth > tf.textWidth [./TextField.as:978]
PASSED: origTextWidth > tf.textWidth [./TextField.as:978]
PASSED: tf._width == 10 [./TextField.as:986]
PASSED: tf._width == 10 [./TextField.as:990]
PASSED: tf._width == 10 [./TextField.as:995]
Expand Down Expand Up @@ -566,6 +566,6 @@ FAILED: expected: 0 obtained: 3 [./TextField.as:1289]
PASSED: this[2] == 3 [./TextField.as:1290]
FAILED: expected: "number" obtained: undefined [./TextField.as:1295]
PASSED: typeof(this.getTime()) == "undefined" [./TextField.as:1299]
#passed: 468
#failed: 88
#passed: 469
#failed: 87
#total tests run: 556
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ PASSED: tf._width > 10 [./TextField.as:965]
PASSED: tf.textWidth == origTextWidth [./TextField.as:966]
After setting wordWrap flat: textWidth: 63 origTextWidth:63
PASSED: tf.textWidth == origTextWidth [./TextField.as:970]
After reducing _width: textWidth: 63 origTextWidth:63
After reducing _width: textWidth: 9 origTextWidth:63
PASSED: tf._width == 10 [./TextField.as:973]
FAILED: origTextWidth > tf.textWidth [./TextField.as:978]
PASSED: origTextWidth > tf.textWidth [./TextField.as:978]
PASSED: tf._width == 10 [./TextField.as:986]
PASSED: tf._width == 10 [./TextField.as:990]
PASSED: tf._width == 10 [./TextField.as:995]
Expand Down Expand Up @@ -566,6 +566,6 @@ FAILED: expected: 0 obtained: 3 [./TextField.as:1289]
PASSED: this[2] == 3 [./TextField.as:1290]
FAILED: expected: "number" obtained: undefined [./TextField.as:1295]
PASSED: typeof(this.getTime()) == "undefined" [./TextField.as:1299]
#passed: 468
#failed: 88
#passed: 469
#failed: 87
#total tests run: 556
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ PASSED: tf._width > 10 [./TextField.as:965]
PASSED: tf.textWidth == origTextWidth [./TextField.as:966]
After setting wordWrap flat: textWidth: 63 origTextWidth:63
PASSED: tf.textWidth == origTextWidth [./TextField.as:970]
After reducing _width: textWidth: 63 origTextWidth:63
After reducing _width: textWidth: 9 origTextWidth:63
PASSED: tf._width == 10 [./TextField.as:973]
FAILED: origTextWidth > tf.textWidth [./TextField.as:978]
PASSED: origTextWidth > tf.textWidth [./TextField.as:978]
PASSED: tf._width == 10 [./TextField.as:986]
PASSED: tf._width == 10 [./TextField.as:990]
PASSED: tf._width == 10 [./TextField.as:995]
Expand Down Expand Up @@ -566,6 +566,6 @@ FAILED: expected: 0 obtained: 3 [./TextField.as:1289]
PASSED: this[2] == 3 [./TextField.as:1290]
FAILED: expected: "number" obtained: undefined [./TextField.as:1295]
PASSED: typeof(this.getTime()) == "undefined" [./TextField.as:1299]
#passed: 468
#failed: 88
#passed: 469
#failed: 87
#total tests run: 556
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ FI
RS
T
LI
10
23
12 changes: 8 additions & 4 deletions tests/tests/swfs/from_shumway/flash_text_TextField2/test.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
num_frames = 1
known_failure = true

[image_comparisons.output]
known_failure = true
tolerance = 3
[[image_comparisons.output.checks]]
tolerance = 200
max_outliers = 10

[[image_comparisons.output.checks]]
tolerance = 128
max_outliers = 250

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