summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/text/shift.rs
diff options
context:
space:
mode:
authorPeng Guanwen <pg999w@outlook.com>2024-12-17 22:07:45 +0800
committerGitHub <noreply@github.com>2024-12-17 14:07:45 +0000
commit73253d465192454f0dfe3fe9eef46d495b343aef (patch)
tree4d8179d7b0d7c169e283471d7df928d264192ca0 /crates/typst-library/src/text/shift.rs
parent54cee16c3128695089d7472451f02646c6d81521 (diff)
Support for defining which charset should be covered by a font (#5305)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates/typst-library/src/text/shift.rs')
-rw-r--r--crates/typst-library/src/text/shift.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/typst-library/src/text/shift.rs b/crates/typst-library/src/text/shift.rs
index 003ecf47..9723bbf0 100644
--- a/crates/typst-library/src/text/shift.rs
+++ b/crates/typst-library/src/text/shift.rs
@@ -157,7 +157,11 @@ fn is_shapable(engine: &Engine, text: &str, styles: StyleChain) -> bool {
.select(family.as_str(), variant(styles))
.and_then(|id| world.font(id))
{
- return text.chars().all(|c| font.ttf().glyph_index(c).is_some());
+ let covers = family.covers();
+ return text.chars().all(|c| {
+ covers.map_or(true, |cov| cov.is_match(c.encode_utf8(&mut [0; 4])))
+ && font.ttf().glyph_index(c).is_some()
+ });
}
}