The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
fix(text): the CJK fallback face covers every character the locales use
Jareer99c3e2640179
diff --git a/assets/windows/concat.iss b/assets/windows/concat.issindex 1cd35265..79e094e5 100644--- a/assets/windows/concat.iss+++ b/assets/windows/concat.iss@@ -66,7 +66,9 @@ ShowLanguageDialog=auto; Every language the app ships. Inno Setup carries the official; translations; the ones it keeps as unofficial - Chinese, Persian,; Croatian - and Korean, official only since 6.5, are vendored in-; languages/ from Inno Setup 6.7.1, so the setup offers them whatever the+; languages/ from the Inno Setup 6.7.1 tree (the Traditional Chinese file+; there is in the 6.1 format, which the compiler still reads, with the+; newer messages in English), so the setup offers them whatever the; compiler on the build machine ships (#277).Name: "english"; MessagesFile: "compiler:Default.isl"Name: "german"; MessagesFile: "compiler:Languages\German.isl"diff --git a/src/crates/concat/fonts/NotoSansCJKsc-Concat.otf b/src/crates/concat/fonts/NotoSansCJKsc-Concat.otfindex be80a322..b70723ea 100644Binary files a/src/crates/concat/fonts/NotoSansCJKsc-Concat.otf and b/src/crates/concat/fonts/NotoSansCJKsc-Concat.otf differdiff --git a/src/crates/concat/src/fonts.rs b/src/crates/concat/src/fonts.rsindex 6586369f..cbd69b8d 100644--- a/src/crates/concat/src/fonts.rs+++ b/src/crates/concat/src/fonts.rs@@ -14,19 +14,23 @@//! is whatever the machine's own fonts make of it. A desk has one; a phone//! from some makers does not, or keeps it where the collection does not//! look, and the interface in Chinese came up as rows of boxes (#277). A-//! subset of Noto Sans CJK - the Simplified and the common Traditional-//! Chinese characters, the Hangul syllables, the kana and the punctuation-//! that goes with them - rides along as the fallback for those scripts,-//! after whatever the machine has.+//! subset of Noto Sans CJK - the everyday Simplified, Traditional and+//! Japanese character sets, the Hangul syllables, the kana and the+//! punctuation that goes with them, and every character the shipped+//! locales use - rides along as the fallback for those scripts, after+//! whatever the machine has.use std::sync::Arc;use slint::fontique_011::fontique::{self, FallbackKey, FamilyId, Language, Script};/// Noto Sans CJK SC, cut to the characters the interface falls back on:-/// GB 2312, the common half of Big5, KS X 1001's Hangul, the kana, and-/// the CJK punctuation and fullwidth forms. Two megabytes rather than-/// sixteen.+/// GB 2312, Big5 level 1, JIS X 0208, KS X 1001's Hangul, the kana, the+/// CJK punctuation and fullwidth forms, and every character in the+/// shipped locales, which the test below holds it to. Under three+/// megabytes rather than sixteen. Japanese and Traditional Chinese read+/// in the Simplified face's forms where the regions differ; on a machine+/// with a font of its own for them, that font comes first.const CJK_FALLBACK: &[u8] = include_bytes!("../fonts/NotoSansCJKsc-Concat.otf");/// Registers every base font with the window's text renderer, and the CJK@@ -37,24 +41,23 @@ pub fn register() {let blob = fontique::Blob::new(Arc::new(face));collection.register_fonts(blob, None);}- let families = register_cjk_fallback(&mut collection);- log::debug!("fonts: {} CJK fallback family registered", families.len());+ let registered = register_cjk_fallback(&mut collection);+ log::debug!("fonts: {} CJK fallback family registered", registered.len());}/// Registers the CJK face with `collection` and appends it to the fallback-/// list of every script it is for, behind whatever the machine has. The-/// families it added.-fn register_cjk_fallback(collection: &mut fontique::Collection) -> Vec<FamilyId> {+/// list of every script it is for, behind whatever the machine has. What+/// was added: each family with its faces.+fn register_cjk_fallback(+ collection: &mut fontique::Collection,+) -> Vec<(FamilyId, Vec<fontique::FontInfo>)> {let blob = fontique::Blob::new(Arc::new(CJK_FALLBACK));- let families: Vec<FamilyId> = collection- .register_fonts(blob, None)- .into_iter()- .map(|(family, _)| family)- .collect();+ let registered = collection.register_fonts(blob, None);+ let families: Vec<FamilyId> = registered.iter().map(|(family, _)| *family).collect();for key in cjk_fallback_keys() {collection.append_fallbacks(key, families.iter().copied());}- families+ registered}/// The fallback lists the face goes on: Han under every locale fontique@@ -108,8 +111,9 @@ mod tests {shared: false,system_fonts: false,});- let families = register_cjk_fallback(&mut collection);- assert_eq!(families.len(), 1);+ let registered = register_cjk_fallback(&mut collection);+ assert_eq!(registered.len(), 1);+ let families: Vec<FamilyId> = registered.iter().map(|(family, _)| *family).collect();assert_eq!(collection.family_name(families[0]),Some("Noto Sans CJK SC")@@ -128,6 +132,37 @@ mod tests {assert_eq!(listed, families);}+ /// The face has a glyph for every character the shipped locales use,+ /// so no word of the interface is a box on a machine with no CJK font+ /// of its own. Read off the font's own character map.+ #[test]+ fn the_cjk_face_covers_every_locale() {+ let mut collection = fontique::Collection::new(fontique::CollectionOptions {+ shared: false,+ system_fonts: false,+ });+ let registered = register_cjk_fallback(&mut collection);+ let face = ®istered[0].1[0];+ let charmap = face+ .charmap_index()+ .charmap(CJK_FALLBACK)+ .expect("the face has a character map");+ let locales = [+ ("ja", include_str!("../locales/ja.json")),+ ("ko", include_str!("../locales/ko.json")),+ ("zh-Hans", include_str!("../locales/zh-Hans.json")),+ ("zh-TW", include_str!("../locales/zh-TW.json")),+ ];+ for (code, text) in locales {+ let missing: Vec<char> = text+ .chars()+ .filter(|ch| u32::from(*ch) > 0x2E7F)+ .filter(|ch| charmap.map(*ch).is_none_or(|glyph| glyph == 0))+ .collect();+ assert!(missing.is_empty(), "{code} has no glyph for {missing:?}");+ }+ }+#[test]fn every_fallback_key_is_listed_once() {let keys = cjk_fallback_keys();