From 74a8a1d2dfa3235c6d12840360123c7836e5f24e Mon Sep 17 00:00:00 2001 From: ".CooCoo" Date: Tue, 10 Nov 2026 03:01:17 -0800 Subject: [PATCH] Fonts: the MTEXT strip test expects a short \U+ escape to keep its digits (#2954) strips_formatting expected `\U+12` to strip to nothing. plain_mtext dropped every unknown code up to the next `;` when that assertion was written. #1036 limits this to the codes in takes_arg, and `\U` is not one of them, so plain_mtext returns `+12`. The layout and paragraph paths give the same text, and unicode_escapes_are_decoded_in_every_parser already expects it. The test has failed on main since both changes merged, and the failure stops the gate at its test step. The test module now also checks the short escape in both layout paths. (cherry picked from commit 6f0f1fefa81d08031bde56a8b3d5b1556810f397) --- crates/fonts/src/mtext.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/fonts/src/mtext.rs b/crates/fonts/src/mtext.rs index e2ff9a3f9..9fe7aa47e 100644 --- a/crates/fonts/src/mtext.rs +++ b/crates/fonts/src/mtext.rs @@ -904,7 +904,7 @@ mod tests { assert_eq!(plain_mtext("\\H2.5x;Big"), "Big"); assert_eq!(plain_mtext("unterminated \\H2"), "unterminated "); assert_eq!(plain_mtext("\\U+0041B \\U+00E8"), "AB รจ"); - assert_eq!(plain_mtext("\\U+12"), "", "a short escape is a code with an argument"); + assert_eq!(plain_mtext("\\U+12"), "+12", "a short escape loses only the backslash and the code"); } #[test] @@ -928,6 +928,8 @@ mod tests { assert_eq!(plain_mtext("\\M+5BCFE x;y"), "\u{4ef6} x;y"); // Malformed escapes lose only the backslash and the code. assert_eq!(plain_mtext("a\\U+12 b"), "a+12 b"); + assert_eq!(lay("a\\U+12 b", 0.0).lines, vec!["a+12 b"]); + assert_eq!(lay("\\pxql;a\\U+12 b", 0.0).lines, vec!["a+12 b"]); assert_eq!(plain_mtext("a\\M+ b"), "a+ b"); }