diff --git a/ROADMAP.md b/ROADMAP.md index 17f0e781..b5185798 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -138,7 +138,7 @@ grade by behaviour against `plan/illustrator/`, not by whether a menu item exist - Pathfinder (10 exact curve booleans), Offset, Outline Stroke, Simplify, Clean Up, Split Into Grid, Divide Objects Below. Object › Path › Remove Anchor Points (`path.removeAnchors`) removes the direct-selected anchors without opening their paths (the Delete key still deletes them with their segments): the neighbours keep their handle directions and their facing handles are refitted so one cubic follows the two old segments, and straight sides stay straight. The Delete Anchor Point tool uses the same refit. The Control bar, the contextual task bar, the Properties quick actions and the canvas context menu offer it when anchors are selected. With anchors selected, the Control bar and the Properties panel also convert them to corner or smooth (`path.convertAnchors`), connect end points (Join) and cut the path at them (`path.cutAtAnchors`, also on the task bar and the context menu): a closed path opens there and an open one becomes one path per piece, each cut leaving one of its two coincident anchors selected so a drag pulls the path apart. - Live effects with previewing dialogs: Distort & Transform, Path, Convert to Shape, 15 Warp styles, Round Corners, Scribble, Effect → Pathfinder (all 10 operations, live on groups; several loose objects are grouped first, in one undo step), Color Adjustments (Brightness/Contrast, Curves, Levels, Hue/Saturation, Shift to Color, Temperature/Tint, on vectors, live type and embedded images), and raster drop shadow, glows and feather. SVG and PDF export keep live effects (geometry baked; SVG raster effects as filters). - **Type:** Text Wrap, Type on a Path effects (Rainbow/Skew/3D Ribbon/Stair Step/Gravity) and Options (Flip, Align to Path, Spacing; OK keeps the type where it is), type on a path's start, centre and end brackets (Selection and Direct Selection drag them to set where the type runs, slide it along its path and, across the path, flip it: #429), Character and Paragraph Styles (override-preserving redefine), Area Type Options (rows/columns/inset/first baseline), threaded text across any closed shapes, Fit Headline. Area type resizes like Illustrator's type areas: a bounding-box handle drag (Selection tool) or Area Type Options Width/Height size the frame and the text reflows at its size (threads too); Direct Selection drags a frame corner or edge (`text.reshapeArea`). Point type still scales. The Selection tool shows the type widget beside selected type's bounding box (hollow on point type, filled on area type); double-clicking it converts between them (Type › Convert To Area Type / Convert To Point Type), keeping the text and its styles in place. Variable fonts list every named instance as a style of their family (Figtree Light to Black and their italics, Bahnschrift, Segoe UI Variable), and the instance chosen is shaped, drawn, outlined and measured at its axis settings; PDF and SVG embed it as that instance. Variation axis sliders are not done. Hebrew and Arabic are laid out right to left with the Unicode bidirectional algorithm (embedded Latin and numbers keep their direction, lines put in visual order after wrapping) in point, area and path type, with caret, selection and arrow keys in visual order; each paragraph's direction comes from its first strong character unless Paragraph Direction sets it (Paragraph panel with Show Indic Options, `text.setFormat {direction}`), and new type aligns to the start of its direction. SVG export outlines right-to-left text. Font Size and Leading are combo boxes in the Character and Properties panels (Font Size in the Control bar too, beside the Character link, font family and style): type, step with ↑/↓ or the spinner, scrub the label, or pick a preset (6–72 pt, shown in the type unit; Leading also Auto), each pick one undo step; Kerning and Tracking list -100…200; a size, leading, kerning or tracking the selected text doesn't share shows blank (#458). -- **Interface languages, vertical type:** VectorCraft ▸ Language (or Preferences ▸ User Interface) picks Automatic (the system locale) or a registered language, persisted as `interfaceLanguage`. Translations come from per-language catalogs (`i18n/*.tsv`): Traditional and Simplified Chinese, Japanese, Spanish (neutral international Spanish, for every `es-*` locale) and Italian (every `it-*` locale) cover the whole interface, Czech and Brazilian Portuguese every menu label, Brazilian Portuguese the shell's `tl!` literals too (tested); Spanish and Italian also translate status-bar and error messages as they are shown (`@msg` templates, every message literal tested; the messages themselves stay English for agents); untranslated text stays English. Japanese and Chinese glyphs come from the craft-fonts build input (release builds) or the installed fonts, Czech, Spanish and Italian ones from the bundled UI fonts. The web app follows the browser's languages (or `?lang=`). The Basic toolbar's Type button holds Vertical Type in its flyout. Vertical Type, Vertical Area Type and Vertical Type on a Path create vertical text (columns right to left, upright CJK glyphs and marks with `vert` alternates, Latin and longer numbers on their side, two- and three-digit numbers set as tate-chu-yoko in one em of the column (kept whole when justified), upright glyphs centred on the column (tracked or justified too), point type's anchor on the first column's centre line); kinsoku (the strict set) applies to horizontal and vertical Japanese, and justified Japanese lines spread their room between characters (not inside Latin words); Paragraph panel › Mojikumi Set (shown with Preferences › Type › Show East Asian Options, `text.setFormat {mojikumi}`): None or Line-end Punctuation Half Width (new type's default, as in Illustrator; older documents and imported text keep None) shares one half-em space between consecutive punctuation, sets a closing mark ending a line half width and an opening bracket starting a wrapped line flush with its start, and puts a quarter em between Japanese and Latin letters or digits; Paragraph panel menu › Top-to-Top / Bottom-to-Bottom Leading measures leading from em box top to top (area type's first line touches the frame) or from baseline to baseline; Paragraph panel menu › Burasagari None / Regular / Force (`text.setFormat {burasagari: "none"|"standard"|"forced"}`) hangs an East Asian comma or full stop (、。,.、。) ending an area type line outside it, Regular (new type's default) when it doesn't fit and Force always (the rest of the line then fills the measure; closing brackets and Latin punctuation don't hang); Character panel menu › Character Alignment (with the East Asian options; `text.setFormat` or `text.setRangeStyle {charAlign}`) lines characters smaller than the largest on their line up on the Roman baseline or the em box top/right, centre or bottom/left (ICF top and bottom not yet); Type ▸ Type Orientation switches existing text; caret, selection, hit testing and arrow keys follow the writing direction. Vertical text exports to PDF as real text and to SVG as outlines. +- **Interface languages, vertical type:** VectorCraft ▸ Language (or Preferences ▸ User Interface) picks Automatic (the system locale) or a registered language, persisted as `interfaceLanguage`. Translations come from per-language catalogs (`i18n/*.tsv`): Traditional and Simplified Chinese, Japanese, Spanish (neutral international Spanish, for every `es-*` locale) and Italian (every `it-*` locale) cover the whole interface, Czech and Brazilian Portuguese every menu label, Brazilian Portuguese the shell's `tl!` literals too (tested); Spanish and Italian also translate status-bar and error messages as they are shown (`@msg` templates, every message literal tested; the messages themselves stay English for agents); untranslated text stays English. Japanese and Chinese glyphs come from the craft-fonts build input (release builds) or the installed fonts, Czech, Spanish and Italian ones from the bundled UI fonts. The web app follows the browser's languages (or `?lang=`). The Basic toolbar's Type button holds Vertical Type in its flyout. Vertical Type, Vertical Area Type and Vertical Type on a Path create vertical text (columns right to left, upright CJK glyphs and marks with `vert` alternates, Latin and longer numbers on their side, two- and three-digit numbers set as tate-chu-yoko in one em of the column (kept whole when justified), upright glyphs centred on the column (tracked or justified too), point type's anchor on the first column's centre line); kinsoku (the strict set) applies to horizontal and vertical Japanese, and justified Japanese lines spread their room between characters (not inside Latin words); Paragraph panel › Mojikumi Set (shown with Preferences › Type › Show East Asian Options, `text.setFormat {mojikumi}`): None or Line-end Punctuation Half Width (new type's default, as in Illustrator; older documents and imported text keep None) shares one half-em space between consecutive punctuation, sets a closing mark ending a line half width and an opening bracket starting a wrapped line flush with its start, and puts a quarter em between Japanese and Latin letters or digits; Paragraph panel menu › Top-to-Top / Bottom-to-Bottom Leading measures leading from em box top to top (area type's first line touches the frame) or from baseline to baseline (new type in a Japanese interface starts top to top, with em box centre character alignment, #432); Paragraph panel menu › Burasagari None / Regular / Force (`text.setFormat {burasagari: "none"|"standard"|"forced"}`) hangs an East Asian comma or full stop (、。,.、。) ending an area type line outside it, Regular (new type's default) when it doesn't fit and Force always (the rest of the line then fills the measure; closing brackets and Latin punctuation don't hang); Character panel menu › Character Alignment (with the East Asian options; `text.setFormat` or `text.setRangeStyle {charAlign}`) lines characters smaller than the largest on their line up on the Roman baseline or the em box top/right, centre or bottom/left (ICF top and bottom not yet); Type ▸ Type Orientation switches existing text; caret, selection, hit testing and arrow keys follow the writing direction. Vertical text exports to PDF as real text and to SVG as outlines. - **Transparency:** opacity masks (clip/invert/disable/link), exported as SVG `` and PDF soft masks. - **Advanced art:** live Blends (steps/distance/smooth colour, editable spine, anchor-targeted Blend tool, faithful interpolation, knockout), Envelope Distort (warp/mesh/top object, Reset, full Envelope Options, mesh handles, Edit Contents; type, images, symbols, gradients, patterns and appearance distorted everywhere), Liquify tools with options and pen pressure, Puppet Warp with rotating pins, Perspective Grid with presets, movable planes and projected type (choosing a perspective tool shows the grid; Hide Grid hides it with the tool still chosen), Gradient Mesh, Shape Builder (stroke-only open paths and lines cut the regions they cross and enclose regions of their own; filled open paths count as closed; erase mode while Alt/Option is held: a minus pointer, red highlights of what will go, a click or drag deletes the regions touched, the pieces of open lines and the edges (outline pieces between the points where paths meet, opening their paths there) it passes over, one undo step, `shapeBuilder.merge {erase}` and `shapeBuilder.regions` edges over MCP), Live Paint (every path an edge, open lines included), Image Trace (12 presets; with an image selected the Control bar and the Properties panel show Image Trace, whose arrow traces with any preset, Mask (`object.maskImage`: a clipping path on the image's outline, selected so its handles crop), Crop Image and Embed or Unembed in place of Fill and Stroke; with an Image Trace object selected, its Preset (choosing another traces again), the Image Trace panel and Expand, plus Release in Properties; the View modes are not done), pattern swatches with pattern editing mode, live Repeat (radial/grid/mirror). - **Paint and appearance (M3):** diff --git a/crates/engine/src/cmd/create.rs b/crates/engine/src/cmd/create.rs index 0c2b4042..ab72da2a 100644 --- a/crates/engine/src/cmd/create.rs +++ b/crates/engine/src/cmd/create.rs @@ -50,7 +50,7 @@ pub fn specs() -> Vec { "Create Text", [], None, - "{x, y, text, vertical?: bool = false, size?: pt, font?: family, style?, color?, area?: {width, height}, placeholder?: bool (fill it with placeholder text instead, as the Type tools do with prefs placeholderText)} → {id}", + "{x, y, text, vertical?: bool = false, size?: pt, font?: family, style?, color?, area?: {width, height}, placeholder?: bool (fill it with placeholder text instead, as the Type tools do with prefs placeholderText), leadingModel?: \"romanBaseline\"|\"emBoxTop\", charAlign?: \"romanBaseline\"|\"emBoxTop\"|\"emBoxCenter\"|\"emBoxBottom\" (default: emBoxTop and emBoxCenter while the interface is in Japanese, else romanBaseline)} → {id}", has_doc, text_create ), @@ -409,6 +409,7 @@ fn text_create(s: &mut Session, p: &Value) -> Result { let mut t = TextObject::point(Point::new(x, y), text, new_type_style(s, p)); t.vertical = p.get("vertical").and_then(Value::as_bool).unwrap_or(false); t.para = new_type_para(); + new_type_alignment(s, p, "text.create", &mut t)?; if let Some(a) = p.get("area") { let w = f64_or(a, "width", 200.0); let h = f64_or(a, "height", 100.0); @@ -435,6 +436,40 @@ pub(crate) fn new_type_para() -> vectorcraft_doc::ParaStyle { } } +/// The leading model and character alignment new type starts with (`t`'s paragraph and runs): +/// `leadingModel` and `charAlign` from `p`, else em box top to top and em box centre while the +/// interface is in Japanese (#432), else the Roman baseline for both. Noted in the journal, so a +/// replay sets the same whatever the interface. +pub(crate) fn new_type_alignment(s: &mut Session, p: &Value, cmd: &str, t: &mut TextObject) -> Result<()> { + use vectorcraft_doc::{CharAlign, LeadingModel}; + let japanese = s.japanese_interface(); + let leading = match p.get("leadingModel").filter(|v| !v.is_null()) { + Some(v) => match v.as_str() { + Some("romanBaseline") => LeadingModel::RomanBaseline, + Some("emBoxTop") => LeadingModel::EmBoxTop, + _ => return Err(bad(cmd, "`leadingModel` must be \"romanBaseline\" or \"emBoxTop\"")), + }, + None => { + let l = if japanese { LeadingModel::EmBoxTop } else { LeadingModel::RomanBaseline }; + s.note_journal("leadingModel", json!(l)); + l + } + }; + let align = match super::textedit::char_align_param(p, cmd)? { + Some(a) => a, + None => { + let a = if japanese { CharAlign::EmBoxCenter } else { CharAlign::RomanBaseline }; + s.note_journal("charAlign", json!(a)); + a + } + }; + t.para.leading_model = leading; + for r in &mut t.runs { + r.style.char_align = align; + } + Ok(()) +} + /// The character style new type gets: `size`, `font`, `style` and `color` from `p`, else the /// defaults, filled with the current fill unless that is None or white (black then). pub(crate) fn new_type_style(s: &Session, p: &Value) -> CharStyle { diff --git a/crates/engine/src/cmd/textedit.rs b/crates/engine/src/cmd/textedit.rs index 6bc50072..9ae8d384 100644 --- a/crates/engine/src/cmd/textedit.rs +++ b/crates/engine/src/cmd/textedit.rs @@ -45,7 +45,7 @@ pub fn specs() -> Vec { "Area / Path Type", [], None, - "{path: id, mode: \"area\"|\"onPath\", text?: \"\", vertical?: bool = false, at?: [x, y] (on-path start: nearest point), size?, font?, placeholder?: bool (placeholder text instead, as text.create)} turn a path into an area-type frame or a type-on-a-path baseline (the path's paint is dropped) → {id}", + "{path: id, mode: \"area\"|\"onPath\", text?: \"\", vertical?: bool = false, at?: [x, y] (on-path start: nearest point), size?, font?, placeholder?: bool (placeholder text instead, as text.create), leadingModel?, charAlign? (as text.create)} turn a path into an area-type frame or a type-on-a-path baseline (the path's paint is dropped) → {id}", has_doc, create_in_path ), @@ -471,6 +471,7 @@ fn create_in_path(s: &mut Session, p: &Value) -> Result { cached_bounds: None, cached_baselines: Vec::new(), }; + super::create::new_type_alignment(s, p, C, &mut t)?; if bool_or(p, "placeholder", false) { super::typemenu::fill_with_placeholder(&mut t); } else { diff --git a/crates/engine/src/cmd/textstyles.rs b/crates/engine/src/cmd/textstyles.rs index f11204a8..f8e58db8 100644 --- a/crates/engine/src/cmd/textstyles.rs +++ b/crates/engine/src/cmd/textstyles.rs @@ -261,6 +261,26 @@ fn attrs_param(p: &Value, kind: Kind, verb: &str) -> Result Map { + if !s.japanese_interface() { + return Map::new(); + } + let (set, default) = match kind { + Kind::Char => { + let st = CharStyle { char_align: vectorcraft_doc::CharAlign::EmBoxCenter, ..CharStyle::default() }; + (to_attrs(&st), to_attrs(&CharStyle::default())) + } + Kind::Para => { + let st = ParaStyle { leading_model: vectorcraft_doc::LeadingModel::EmBoxTop, ..ParaStyle::default() }; + (to_attrs(&st), to_attrs(&ParaStyle::default())) + } + }; + set.into_iter().filter(|(k, v)| default.get(k) != Some(v)).collect() +} + // ---------- commands ---------- fn list(s: &mut Session, kind: Kind) -> Result { @@ -275,7 +295,14 @@ fn new(s: &mut Session, p: &Value, kind: Kind) -> Result { let c = kind.cmd("new"); let attrs = match attrs_param(p, kind, "new")? { Some(a) => a, - None => selection_attrs(s, p, kind)?.unwrap_or_default(), + None => match selection_attrs(s, p, kind)? { + Some(a) => a, + None => { + let a = new_style_attrs(s, kind); + s.note_journal("attrs", Value::Object(a.clone())); + a + } + }, }; let d = &s.doc()?.doc; let base = if kind == Kind::Char { "Character Style" } else { "Paragraph Style" }; diff --git a/crates/engine/src/cmd/typecmd.rs b/crates/engine/src/cmd/typecmd.rs index 4cd3b4e8..7c830ff7 100644 --- a/crates/engine/src/cmd/typecmd.rs +++ b/crates/engine/src/cmd/typecmd.rs @@ -444,6 +444,73 @@ mod area_tests { assert_eq!(old.burasagari, Burasagari::None); } + /// #432: while the interface is in Japanese, new type (text.create, text.createInPath) starts + /// with em box top-to-top leading and em box centre alignment, and new styles made from nothing + /// carry them; params override; the values are journaled; imported text keeps the Roman + /// baseline. + #[test] + fn new_type_takes_the_japanese_defaults_while_the_interface_is_japanese() { + use vectorcraft_doc::{CharAlign, LeadingModel}; + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap(); + let made = |s: &mut Session, cmd: &str, p: Value| -> (LeadingModel, CharAlign) { + let id = s.execute(cmd, &p).unwrap()["id"].as_u64().unwrap(); + match &s.doc().unwrap().doc.node(NodeId(id)).unwrap().kind { + NodeKind::Text(t) => (t.para.leading_model, t.runs[0].style.char_align), + _ => panic!("text"), + } + }; + let roman = (LeadingModel::RomanBaseline, CharAlign::RomanBaseline); + let japanese = (LeadingModel::EmBoxTop, CharAlign::EmBoxCenter); + let point = json!({"x": 10, "y": 50, "text": "雅楽"}); + assert!(!s.japanese_interface()); + assert_eq!(made(&mut s, "text.create", point.clone()), roman, "headless, `auto`: the Roman defaults"); + s.ui_language = Some("ja".into()); + assert_eq!(made(&mut s, "text.create", point.clone()), japanese); + assert_eq!(made(&mut s, "text.create", json!({"x": 10, "y": 90, "text": "笙", "area": {"width": 100, "height": 50}})), japanese); + // Journaled: a replay in another language does the same. + let (_, logged) = s.journal.last().unwrap().clone(); + assert_eq!((logged["leadingModel"].as_str(), logged["charAlign"].as_str()), (Some("emBoxTop"), Some("emBoxCenter"))); + // Params override. + assert_eq!( + made(&mut s, "text.create", json!({"x": 10, "y": 120, "text": "a", "leadingModel": "romanBaseline", "charAlign": "romanBaseline"})), + roman + ); + assert!(s.execute("text.create", &json!({"x": 0, "y": 0, "text": "a", "leadingModel": "middle"})).is_err()); + // Area type in a path. + let path = s.execute("shape.rectangle", &json!({"x": 200, "y": 200, "width": 100, "height": 80})).unwrap()["id"].clone(); + assert_eq!(made(&mut s, "text.createInPath", json!({"path": path, "mode": "area", "text": "篳篥"})), japanese); + // A preference set to Japanese counts without a UI; another language doesn't. + s.ui_language = None; + s.prefs.interface_language = "ja".into(); + assert_eq!(made(&mut s, "text.create", point.clone()), japanese); + s.ui_language = Some("en".into()); + assert_eq!(made(&mut s, "text.create", point.clone()), roman); + // New styles made from nothing. + s.execute("select.set", &json!({"ids": []})).unwrap(); + s.ui_language = Some("ja".into()); + let style = |s: &mut Session, kind: &str| { + let name = s.execute(&format!("{kind}.new"), &json!({})).unwrap()["name"].as_str().unwrap().to_string(); + let list = s.execute(&format!("{kind}.list"), &json!({})).unwrap(); + list["styles"].as_array().unwrap().iter().find(|st| st["name"] == name.as_str()).unwrap()["attrs"].clone() + }; + assert_eq!(style(&mut s, "paraStyle"), json!({"leading_model": "emBoxTop"})); + assert_eq!(style(&mut s, "charStyle"), json!({"charAlign": "emBoxCenter"})); + s.ui_language = Some("en".into()); + assert_eq!(style(&mut s, "paraStyle"), json!({})); + // Imported text keeps the Roman baseline. + s.ui_language = Some("ja".into()); + let svg = r#"雅楽"#; + s.execute("document.open", &json!({"name": "t.svg", "dataBase64": vectorcraft_format::base64_encode(svg.as_bytes())})).unwrap(); + let mut found = vec![]; + s.doc().unwrap().doc.walk(|n| { + if let NodeKind::Text(t) = &n.kind { + found.push((t.para.leading_model, t.runs[0].style.char_align)); + } + }); + assert_eq!(found, [roman]); + } + #[test] fn leading_model_is_set_per_paragraph_and_saved_only_when_top_to_top() { use vectorcraft_doc::LeadingModel; diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index beac971a..def9b65e 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -763,6 +763,10 @@ pub struct Session { pub style_libraries: cmd::stylelib::Libraries, /// URLs recently given in the Attributes panel (`attributes.set {url}`), newest first; not saved. pub recent_urls: Vec, + /// The language the UI is drawn in (a language code, never `auto`), set by the UI each frame; + /// `None` without one (headless), where an explicit `interfaceLanguage` preference counts. + /// Japanese gives new type the Japanese defaults ([`Session::japanese_interface`]). + pub ui_language: Option, /// Parameters the running top-level command resolved from the preferences or the clock, added /// to its journal entry so a replay does the same ([`Session::note_journal`]). journal_note: serde_json::Map, @@ -825,6 +829,7 @@ impl Session { freeform_point: None, style_libraries: Default::default(), recent_urls: vec![], + ui_language: None, journal_note: Default::default(), note_depth: 1, batch_stash: None, @@ -996,6 +1001,12 @@ impl Session { Ok(r) } + /// Is the interface in Japanese? Then new type starts with em box top-to-top leading and em + /// box centre character alignment (#432). + pub fn japanese_interface(&self) -> bool { + self.ui_language.as_deref().unwrap_or(&self.prefs.interface_language).eq_ignore_ascii_case("ja") + } + /// Record `key: value` in the running top-level command's journal entry (or its interaction's /// preview, or its step in a batch) unless its params give `key`: a value it resolved from the /// preferences or the clock. diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index a6008cef..f594026e 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -171,6 +171,24 @@ fn partial_catalogs_only_translate_strings_the_ui_shows() { } } +/// The engine learns the language the UI is drawn in each frame: new type takes the Japanese +/// defaults while it is Japanese (#432). +#[test] +fn the_engine_follows_the_interface_language() { + let mut app = crate::VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + let ctx = egui::Context::default(); + let frame = |app: &mut crate::VectorcraftApp| { + ctx.run_ui(egui::RawInput::default(), |ui| app.logic(ui.ctx())).textures_delta.clear(); + }; + frame(&mut app); + assert_eq!(app.session.ui_language.as_deref(), Some("en"), "tests resolve `auto` to English"); + assert!(!app.session.japanese_interface()); + app.session.prefs.interface_language = "ja".into(); + frame(&mut app); + assert_eq!(app.session.ui_language.as_deref(), Some("ja")); + assert!(app.session.japanese_interface()); +} + /// VectorCraft › Language (`app.language`) sets the `interfaceLanguage` preference, which is what /// persists; the checked item follows the preference, and a bad code is an error, not a change. #[test] diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index e2b8c0cd..b01bc125 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -726,7 +726,12 @@ impl VectorcraftApp { } fn logic_frame(&mut self, ctx: &egui::Context) { - i18n::set_current(self.ui_language()); + let lang = self.ui_language(); + i18n::set_current(lang); + // The engine gives new type the Japanese defaults while the UI is in Japanese. + if self.session.ui_language.as_deref() != Some(lang.code()) { + self.session.ui_language = Some(lang.code().to_string()); + } self.adopt_context(ctx); if !self.styled { theme::install_fonts(ctx); diff --git a/docs/mcp.md b/docs/mcp.md index e681bcb1..a9aa755b 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2179,6 +2179,19 @@ undo step. {"name":"run_command","arguments":{"command":"text.setFormat","params":{"burasagari":"forced"}}} ``` +## New type in a Japanese interface + +While the interface is in Japanese (VectorCraft › Language, or `auto` on a Japanese system), new type starts with em +box top-to-top leading (`leadingModel: "emBoxTop"`) and em box centre character alignment (`charAlign: "emBoxCenter"`); +in other languages it starts on the Roman baseline (#432). This covers the Type tools, +`text.create` and `text.createInPath`, which also take `leadingModel` and `charAlign` to choose, and `paraStyle.new` / +`charStyle.new` made with no `attrs` and no text selected. The values used are kept in the journal, so a replay sets the +same in any language. Saved documents keep what they say, and imported text (PDF, SVG, DXF…) keeps the Roman baseline. + +```json +{"name":"run_command","arguments":{"command":"text.create","params":{"x":40,"y":60,"text":"雅楽","leadingModel":"emBoxTop","charAlign":"emBoxCenter"}}} +``` + ## Moving and flipping type on a path Type on a path flows between a start and an end bracket, stored as fractions of its path's length.