diff --git a/crates/typst-library/src/text/font/book.rs b/crates/typst-library/src/text/font/book.rs index db100d4f7..c9b8f3065 100644 --- a/crates/typst-library/src/text/font/book.rs +++ b/crates/typst-library/src/text/font/book.rs @@ -7,7 +7,9 @@ use ttf_parser::{PlatformId, Tag, name_id}; use unicode_segmentation::UnicodeSegmentation; use super::exceptions::find_exception; -use crate::text::{Font, FontStretch, FontStyle, FontVariant, FontWeight}; +use crate::text::{ + Font, FontStretch, FontStyle, FontVariant, FontWeight, is_default_ignorable, +}; /// Metadata about a collection of fonts. #[derive(Debug, Default, Clone, Hash)] @@ -99,8 +101,12 @@ impl FontBook { variant: FontVariant, text: &str, ) -> Option { - // Find the fonts that contain the text's first non-space char ... - let c = text.chars().find(|c| !c.is_whitespace())?; + // Find the fonts that contain the text's first non-space and + // non-ignorable char ... + let c = text + .chars() + .find(|&c| !c.is_whitespace() && !is_default_ignorable(c))?; + let ids = self .infos .iter() diff --git a/tests/ref/issue-5276-shaping-consecutive-ltr-with-lang.png b/tests/ref/issue-5276-shaping-consecutive-ltr-with-lang.png new file mode 100644 index 000000000..2d7ddb361 Binary files /dev/null and b/tests/ref/issue-5276-shaping-consecutive-ltr-with-lang.png differ diff --git a/tests/ref/issue-5490-bidi-invalid-range-2.png b/tests/ref/issue-5490-bidi-invalid-range-2.png index f93b6309b..58f2c40ce 100644 Binary files a/tests/ref/issue-5490-bidi-invalid-range-2.png and b/tests/ref/issue-5490-bidi-invalid-range-2.png differ diff --git a/tests/suite/layout/inline/bidi.typ b/tests/suite/layout/inline/bidi.typ index d7601fa1d..103ab6030 100644 --- a/tests/suite/layout/inline/bidi.typ +++ b/tests/suite/layout/inline/bidi.typ @@ -92,3 +92,7 @@ Lריווח #h(1cm) R #text(lang: "ar")[سلام] ], ) + +--- issue-5276-shaping-consecutive-ltr-with-lang --- +#let a = text(lang: "ar")[\u{645}] +#a#a