diff options
| author | bluebear94 <uruwi@protonmail.com> | 2023-10-03 09:04:15 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-03 15:04:15 +0200 |
| commit | d709b0e2479d780625becc2f493ce4067aa20cb3 (patch) | |
| tree | 33d05ce4bc8d77692a8a64e7af99a9443517c05a /crates/typst-library/src/text | |
| parent | ce658db2f39f8472c3525a18ed1cfead23781fbb (diff) | |
Honor text’s fallback option for hyphenation (#2301)
Diffstat (limited to 'crates/typst-library/src/text')
| -rw-r--r-- | crates/typst-library/src/text/shaping.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/typst-library/src/text/shaping.rs b/crates/typst-library/src/text/shaping.rs index 57501c52..73ae0779 100644 --- a/crates/typst-library/src/text/shaping.rs +++ b/crates/typst-library/src/text/shaping.rs @@ -429,12 +429,17 @@ impl<'a> ShapedText<'a> { } /// Push a hyphen to end of the text. - pub fn push_hyphen(&mut self, vt: &Vt) { + pub fn push_hyphen(&mut self, vt: &Vt, fallback: bool) { let world = vt.world; let book = world.book(); + let fallback_func = if fallback { + Some(|| book.select_fallback(None, self.variant, "-")) + } else { + None + }; let mut chain = families(self.styles) .map(|family| book.select(family.as_str(), self.variant)) - .chain(std::iter::once_with(|| book.select_fallback(None, self.variant, "-"))) + .chain(fallback_func.iter().map(|f| f())) .flatten(); chain.find_map(|id| { |
