mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 06:38:44 +00:00
Use shared cluster font fallback
This commit is contained in:
Generated
+1
-1
@@ -1008,7 +1008,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=6d620e971e820b517b11a9
|
||||
[[package]]
|
||||
name = "craft-font-catalog"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=11f54a35ff8a62f06b752c752c7ab5c991f4de7a#11f54a35ff8a62f06b752c752c7ab5c991f4de7a"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=1a2b3b327f033f83a59363b5e7d236bc6f0fe122#1a2b3b327f033f83a59363b5e7d236bc6f0fe122"
|
||||
dependencies = [
|
||||
"harfrust 0.13.3",
|
||||
"kurbo 0.13.1",
|
||||
|
||||
@@ -10,7 +10,7 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
# Pending shared extraction; pin the immutable official PR head until it merges.
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "11f54a35ff8a62f06b752c752c7ab5c991f4de7a", default-features = false }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "1a2b3b327f033f83a59363b5e7d236bc6f0fe122", default-features = false }
|
||||
vectorcraft-geom = { workspace = true }
|
||||
vectorcraft-doc = { workspace = true }
|
||||
kurbo = { workspace = true }
|
||||
|
||||
@@ -1221,10 +1221,7 @@ fn shapes_alike(a: &CharStyle, b: &CharStyle) -> bool {
|
||||
/// `digits`: not what the layout handles itself (tab, line and paragraph breaks), joiners or
|
||||
/// variation selectors.
|
||||
fn drawn_chars(cluster: &str, digits: Digits) -> impl Iterator<Item = char> + '_ {
|
||||
cluster
|
||||
.chars()
|
||||
.map(move |c| digits.map(c))
|
||||
.filter(|&c| !(c.is_control() || matches!(c, '\u{200C}' | '\u{200D}' | '\u{2028}' | '\u{FE00}'..='\u{FE0F}' | '\u{E0100}'..='\u{E01EF}')))
|
||||
craft_font_catalog::drawable_characters(cluster, move |c| digits.map(c))
|
||||
}
|
||||
|
||||
/// Does the face with charmap `map` have a glyph for `c` (any face does when it has no charmap)?
|
||||
@@ -1236,11 +1233,14 @@ fn in_face(map: Option<&Charmap<'_>>, c: char) -> bool {
|
||||
/// first fallback face with all of them, so that a letter's marks are shaped with it and attach to
|
||||
/// it (#4491); when there is none, the face its first character takes on its own.
|
||||
fn fallback_face(db: &FontDb, primary: &Arc<FontFace>, pmap: Option<&Charmap<'_>>, cluster: &str, digits: Digits) -> Arc<FontFace> {
|
||||
let fallback = |c| db.fallback_for_style(c, primary.id(), primary.weight, primary.italic);
|
||||
drawn_chars(cluster, digits)
|
||||
.find_map(|c| fallback(c).filter(|f| drawn_chars(cluster, digits).all(|c| f.covers(c))))
|
||||
.or_else(|| drawn_chars(cluster, digits).next().filter(|&c| !in_face(pmap, c)).and_then(fallback))
|
||||
.unwrap_or_else(|| primary.clone())
|
||||
craft_font_catalog::cluster_face(
|
||||
cluster,
|
||||
primary,
|
||||
|c| digits.map(c),
|
||||
|c| in_face(pmap, c),
|
||||
|c| db.fallback_for_style(c, primary.id(), primary.weight, primary.italic),
|
||||
|face, c| face.covers(c),
|
||||
)
|
||||
}
|
||||
|
||||
/// The script `c` is shaped in: Japanese and Chinese text mixes Han, Hiragana, Katakana and
|
||||
|
||||
Reference in New Issue
Block a user