DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
UI: the Properties panel's Character section sets the text's language, from the same list as the Character panel (#130)
aiongg63a1f0349891
diff --git a/ROADMAP.md b/ROADMAP.mdindex 56c9f5a65..588240138 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -88,7 +88,7 @@ DesignCraft aims at full Adobe InDesign parity — and to be better: faster, ope- Edit ▸ Menus (`window.hideMenuItem`): hide menu items; menus with hidden items end in Show All Menu Items.- View ▸ Separations Preview (`view.separations`): one process plate as ink density, or areas over an ink limit in red (a GCR preview of the rendered view; spot plates and the flattener preview aren't there).- Separations Preview plates now come from each object's own colour (CMYK as authored; RGB and images through the colour settings, images via a cached 17³ table), so pure black shows only on the black plate.-- Language (Character panel ▸ Language, `type.char {language}`): text in other languages isn't hyphenated or spell-checked with the English dictionaries, typographer's quotes follow the language (German „…“, French and Russian «…», Swiss, Spanish, Dutch, Nordic, Japanese and Traditional Chinese 「…」, Simplified Chinese “…”), the font's localized forms (OpenType `locl`: Turkish i, Bulgarian Cyrillic, Japanese / Chinese / Korean glyph variants) follow it too, and so does the fallback for CJK characters the font lacks (with Draw Missing Glyphs from Fallback Fonts on): Japanese, Simplified Chinese, Traditional Chinese and Korean each try their own installed system fonts (Japanese starts with the craft-fonts Japanese faces, Mincho first, when built with them; Hangul, kana and Bopomofo pick their language's fonts whatever the language). Language names from IDML keep their spelling; locale codes as InDesign writes them for some languages (`de_DE_2006`, `nl_NL_2005`; any `ll`, `ll_CC`, `ll-CC`) are their language and region for all of the above, and Chinese is also recognised in its common spellings ("Simplified Chinese", "Chinese (Traditional)", `zh_CN`, `zh-Hant`). Hyphenation dictionaries for other languages aren't bundled yet.+- Language (Character panel ▸ Language, Properties ▸ Character, `type.char {language}`): text in other languages isn't hyphenated or spell-checked with the English dictionaries, typographer's quotes follow the language (German „…“, French and Russian «…», Swiss, Spanish, Dutch, Nordic, Japanese and Traditional Chinese 「…」, Simplified Chinese “…”), the font's localized forms (OpenType `locl`: Turkish i, Bulgarian Cyrillic, Japanese / Chinese / Korean glyph variants) follow it too, and so does the fallback for CJK characters the font lacks (with Draw Missing Glyphs from Fallback Fonts on): Japanese, Simplified Chinese, Traditional Chinese and Korean each try their own installed system fonts (Japanese starts with the craft-fonts Japanese faces, Mincho first, when built with them; Hangul, kana and Bopomofo pick their language's fonts whatever the language). Language names from IDML keep their spelling; locale codes as InDesign writes them for some languages (`de_DE_2006`, `nl_NL_2005`; any `ll`, `ll_CC`, `ll-CC`) are their language and region for all of the above, and Chinese is also recognised in its common spellings ("Simplified Chinese", "Chinese (Traditional)", `zh_CN`, `zh-Hant`). Hyphenation dictionaries for other languages aren't bundled yet.- Books (`book.new/open/add/remove/list/styleSource/paginate/syncStyles/exportPdf`, Book panel): `.dcbook` files, continuous page numbering, style sync from a style source, one merged PDF.- Track Changes (`changes.track/list/acceptAll/rejectAll`, Type ▸ Track Changes): typing is marked added (highlighted on screen), deletions are kept but hidden from layout and exports until accepted or rejected. Per-change accept/reject and authors aren't there yet.- Track Changes: per-change Accept / Reject (`changes.accept`, `changes.reject`) and a Track Changes panel listing every change.diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rsindex 8644fe796..0d1bc69a3 100644--- a/crates/ui-egui/src/panels/properties.rs+++ b/crates/ui-egui/src/panels/properties.rs@@ -1070,6 +1070,18 @@ fn character_section(app: &mut DesignApp, ui: &mut Ui) {}) {let _ = app.run("type.char", json!({"attrs": {"tracking": v}}));}+ // Language: hyphenation, spelling and typographer's quotes follow it.+ ui.add_space(1.0);+ let lang = c["language"].as_str().unwrap_or("English: USA").to_string();+ let label = crate::i18n::tr(&app.ui.language, "Language");+ let resp = widgets::dropdown(ui, crate::i18n::tr(&app.ui.language, &lang), fw).on_hover_ui(|ui| {+ crate::rtl::label(ui, label);+ });+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::ComboBox, true, label));+ egui::Popup::menu(&resp).show(|ui| {+ ui.set_min_width(fw);+ egui::ScrollArea::vertical().max_height(320.0).show(ui, |ui| language_menu(app, ui, &lang));+ });if more_options(ui, &app.ui.language).clicked() {app.ui.open_panel = Some("character".into());}@@ -1212,6 +1224,17 @@ const LANGUAGES: &[&str] = &["Hebrew",];+/// The Language list (Character panel, Properties ▸ Character): picking one sets the language of+/// the selected text.+fn language_menu(app: &mut DesignApp, ui: &mut Ui, cur: &str) {+ for l in LANGUAGES {+ if ui.selectable_label(*l == cur, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, l))).clicked() {+ let _ = app.run("type.char", json!({"attrs": {"language": l}}));+ ui.close();+ }+ }+}+pub fn character_panel(app: &mut DesignApp, ui: &mut egui::Ui) {let Some(a) = text_attrs(app) else {crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Select text or a text frame."));@@ -1231,13 +1254,7 @@ pub fn character_panel(app: &mut DesignApp, ui: &mut egui::Ui) {egui::ComboBox::from_id_salt("char_language").selected_text(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, &lang))).width(170.0)- .show_ui(ui, |ui| {- for l in LANGUAGES {- if ui.selectable_label(*l == lang, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, l))).clicked() {- let _ = app.run("type.char", json!({"attrs": {"language": l}}));- }- }- });+ .show_ui(ui, |ui| language_menu(app, ui, &lang));});// Digits (World-Ready): shown for right-to-left paragraphs or once set.let digits = c["digits"].as_str().unwrap_or("default").to_string();@@ -2120,3 +2137,42 @@ fn variable_font_axes(app: &mut DesignApp, ui: &mut egui::Ui, family: &str, styllet _ = app.run("type.char", json!({"attrs": {"fontStyle": format!("{base} {{{spec}}}")}}));}}++#[cfg(test)]+mod tests {+ use egui_kittest::{Harness, kittest::Queryable};++ use super::*;++ fn language(app: &mut DesignApp) -> Value {+ text_attrs(app).unwrap()["chars"]["language"].clone()+ }++ #[test]+ fn properties_character_section_sets_the_language() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ app.run("frame.create", json!({"rect": [72, 72, 300, 200], "content": "text", "text": "bunun", "caret": true})).unwrap();+ app.run("edit.selectAll", json!({})).unwrap();+ assert_ne!(language(&mut app), "French");+ let mut h = Harness::builder().with_size(vec2(320.0, 1400.0)).build_ui_state(+ |ui, app: &mut DesignApp| {+ // The panel's fonts are installed before its first frame.+ let id = egui::Id::new("test_fonts");+ if ui.data(|d| d.get_temp::<bool>(id)).is_none() {+ crate::theme::install_fonts(ui.ctx(), "");+ ui.data_mut(|d| d.insert_temp(id, true));+ return;+ }+ show(app, ui);+ },+ app,+ );+ h.run_steps(3);+ h.get_by_label("Language").click();+ h.run_steps(2);+ h.get_by_label("French").click();+ h.run_steps(2);+ assert_eq!(language(h.state_mut()), "French");+ }+}