Merge main (c9349771) into dialog-controls-named

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
squalorso
2026-10-31 15:37:14 +01:00
co-authored by Claude Opus 5.5
28 changed files with 546 additions and 57 deletions
+8 -1
View File
File diff suppressed because one or more lines are too long
+1 -2
View File
@@ -443,8 +443,7 @@ impl Document {
Ok(id)
}
/// Count words like Word's status bar (whitespace-separated tokens containing a letter or digit,
/// including generated numbered-list labels).
/// Count words like Word's status bar ([`crate::count_words`], plus generated numbered-list labels).
pub fn word_count(&self) -> usize {
self.story_word_count(StoryRef::Body)
}
+31
View File
@@ -18,6 +18,20 @@ fn word_count() {
assert_eq!(count_words(" -- "), 0);
}
/// #4547: each Han ideograph and kana counts as a word; punctuation and Hangul spacing don't change.
#[test]
fn word_count_counts_each_chinese_and_japanese_character() {
// #4547: unspaced Chinese counted as one word per run.
assert_eq!(count_words("我们今天去公园。"), 7);
assert_eq!(count_words("WordCraft是一个文字处理器,很好用!"), 1 + 11);
assert_eq!(count_words("ひらがなとカタカナ"), 9);
assert_eq!(count_words("カタカナ"), 4);
assert_eq!(count_words("ガギ"), 2, "voiced sound marks belong to their kana");
assert_eq!(count_words("。、・「」"), 0);
// Korean is spaced: Hangul counts by tokens.
assert_eq!(count_words("안녕하세요 세계"), 2);
}
#[test]
fn word_count_includes_numbered_list_labels_but_not_bullets() {
let mut d = Document::new();
@@ -63,6 +77,23 @@ fn word_count_includes_numbered_labels_with_nothing_suffix() {
assert_eq!(d.word_count(), 5);
}
/// #4547: a generated CJK list label such as 第十二章 still counts as one word.
#[test]
fn word_count_keeps_a_cjk_list_label_one_word() {
let mut d = Document::new();
let num_id = d.numbering.add_list(ListKind::Numbered);
let aid = d.numbering.num(num_id).expect("list num exists").abstract_id;
let a = d.numbering.abstracts.iter_mut().find(|a| a.id == aid).expect("abstract num exists");
a.levels[0].format = section::NumFormat::ChineseCounting;
a.levels[0].text = "第%1章".into();
a.levels[0].start = 12;
let mut p = Paragraph::with_text("总结", CharProps::default());
p.props.numbering = Some(props::NumRef { num: num_id, level: 0 });
d.body = vec![Arc::new(Block::Para(p))];
// The label 第十二章 stays one word (#4547 changed only document text); 总结 is two.
assert_eq!(d.word_count(), 1 + 2);
}
#[test]
fn sections_and_section_mut() {
let mut d = Document::from_text("a\nb\nc");
+30 -3
View File
@@ -3,9 +3,36 @@ use super::parts::PartKind;
use super::position::Path;
use super::{InlineObject, Numbering, numbering, para, section, styles};
/// Words in `s` (tokens separated by whitespace that contain at least one alphanumeric char).
/// Words in `s`, as Word counts them: tokens separated by whitespace that contain at least one
/// alphanumeric char, plus each Han ideograph and kana as a word of its own (Chinese and Japanese
/// are written without spaces, #4547; Korean is spaced, so Hangul counts by tokens).
pub fn count_words(s: &str) -> usize {
s.split(|c: char| c.is_whitespace() || c == para::OBJ).filter(|w| w.chars().any(char::is_alphanumeric)).count()
// The half-width voiced sound marks belong to the kana before them, not a word of their own.
let word_char = |c: char| c.is_alphanumeric() && !matches!(c, '\u{FF9E}' | '\u{FF9F}');
let tokens = s.split(|c: char| c.is_whitespace() || c == para::OBJ || is_cjk_word(c)).filter(|w| w.chars().any(word_char)).count();
tokens.saturating_add(s.chars().filter(|c| is_cjk_word(*c)).count())
}
/// Words in a generated list label: whitespace-separated tokens holding a letter or digit, so a
/// CJK label such as 第十二章 stays one word (how Word counts those is unverified).
fn count_label_words(s: &str) -> usize {
s.split(char::is_whitespace).filter(|w| w.chars().any(char::is_alphanumeric)).count()
}
/// A Han ideograph or kana letter (not CJK punctuation), which Word counts as one word.
fn is_cjk_word(c: char) -> bool {
matches!(c,
'\u{3005}'..='\u{3007}' // 々 〆 〇
| '\u{3031}'..='\u{3035}' | '\u{303B}' // vertical kana repeat marks, 〻
| '\u{3040}'..='\u{30FF}' // hiragana, katakana
| '\u{31F0}'..='\u{31FF}' // katakana phonetic extensions
| '\u{3400}'..='\u{4DBF}' // extension A
| '\u{4E00}'..='\u{9FFF}' // unified ideographs
| '\u{F900}'..='\u{FAFF}' // compatibility ideographs
| '\u{FF66}'..='\u{FF9D}' // half-width katakana
| '\u{1B000}'..='\u{1B16F}' // kana supplement and extended
| '\u{20000}'..='\u{3FFFF}' // extensions B and later
) && c.is_alphanumeric()
}
/// How deep in nested tables [`Document::para_paths`] goes: cells below this are skipped.
@@ -146,7 +173,7 @@ pub(crate) fn story_word_count_of(
&& let Some((label, def)) = counters.next_label(numbering, n.num, n.level)
&& !matches!(def.format, section::NumFormat::Bullet | section::NumFormat::None)
{
total = total.saturating_add(count_words(&label));
total = total.saturating_add(count_label_words(&label));
}
total = total.saturating_add(count_words(&p.plain_text()));
}
+3 -2
View File
@@ -273,8 +273,9 @@ fn set(s: &mut Session, v: &Value) -> CmdResult {
} else if let (Some(pg), Some(x), Some(y)) = (p::u64(v, "page"), p::f32(v, "x"), p::f32(v, "y")) {
let story = super::story_param(s, v);
let l = s.layout();
s.page_hint = pg as usize;
l.hit(pg as usize, x, y, story).ok_or_else(|| CmdError::Params("no text on that page".into()))?
let page = usize::try_from(pg).unwrap_or(usize::MAX);
s.page_hint = page;
l.hit(page, x, y, story).ok_or_else(|| CmdError::Params("no text on that page".into()))?
} else {
return Err(CmdError::Params("`pos` or `page`/`x`/`y` required".into()));
};
+1 -1
View File
@@ -776,7 +776,7 @@ fn goto(s: &mut Session, v: &Value) -> CmdResult {
});
if let Some(pg) = rel.or_else(|| p::u64(v, "page")) {
let l = s.layout();
let idx = (pg.max(1) as usize - 1).min(l.pages.len().saturating_sub(1));
let idx = crate::p::page_index(pg).min(l.pages.len().saturating_sub(1));
let target = l.pages.get(idx).and_then(|page| {
page.items.iter().find_map(|it| match it {
wordcraft_layout::Placed::Lines { story, path, para, l0, .. } if *story == StoryRef::Body => {
+1 -1
View File
@@ -428,7 +428,7 @@ fn export_png(s: &mut Session, v: &Value) -> CmdResult {
s.push_ui_request(json!({"open": "exportPng"}));
return Ok(json!({"exported": false}));
};
let page = p::u64(v, "page").unwrap_or(1).max(1) as usize - 1;
let page = crate::p::page_index(p::u64(v, "page").unwrap_or(1));
let scale = p::f32(v, "scale").unwrap_or(2.0).clamp(0.1, 8.0);
let l = s.export_layout_with(export_options(s, v).markup);
let pg = l.pages.get(page).ok_or_else(|| CmdError::Params(format!("no page {}", page + 1)))?;
+5
View File
@@ -192,6 +192,11 @@ pub mod p {
pub fn u64(v: &Value, k: &str) -> Option<u64> {
v.get(k).and_then(|x| x.as_u64().or_else(|| x.as_f64().filter(|f| *f >= 0.0 && f.is_finite()).map(|f| f as u64)))
}
/// A 1-based page parameter as a 0-based index. A value that cannot fit in
/// `usize` (32-bit and wasm) saturates instead of wrapping to page 1.
pub fn page_index(page: u64) -> usize {
usize::try_from(page.max(1)).unwrap_or(usize::MAX).saturating_sub(1)
}
pub fn bool(v: &Value, k: &str) -> Option<bool> {
v.get(k).and_then(Value::as_bool)
}
+44 -1
View File
@@ -156,8 +156,20 @@ impl Session {
}
/// The document as the PDF of a print job `v` describes (see [`plan`]), with the number of
/// distinct pages chosen and copies. Does not touch the document.
/// distinct pages chosen and copies, as File › Print › Save these pages as PDF keeps it:
/// links work. Does not touch the document.
pub fn print_pdf(&self, v: &Value) -> Result<(Vec<u8>, PrintPlan), CmdError> {
self.print_pdf_with(v, true)
}
/// The PDF sent to a printer for job `v`: [`Self::print_pdf`] without link annotations,
/// which print nothing, and which a printer driver can't fit to the paper ("flatten page
/// annotations before using shrink-to-fit", #4734).
pub fn print_job_pdf(&self, v: &Value) -> Result<(Vec<u8>, PrintPlan), CmdError> {
self.print_pdf_with(v, false)
}
fn print_pdf_with(&self, v: &Value, links: bool) -> Result<(Vec<u8>, PrintPlan), CmdError> {
// Print Markup (File › Print) decides whether tracked changes and comments print.
let markup = crate::cmd::file::export_options(self, v);
let lay = self.export_layout_with(markup.markup);
@@ -170,6 +182,7 @@ impl Session {
include_markup: markup.markup,
comments: markup.comments,
paper,
links,
..Default::default()
};
let bytes = wordcraft_pdf::export_layout(&self.doc, &lay, &opts).map_err(|e| CmdError::Failed(e.to_string()))?;
@@ -238,6 +251,36 @@ mod tests {
assert!(r, "printPdf needs a path");
}
/// #4734: the PDF sent to a printer has no link annotations, which a printer driver can't fit
/// to the paper ("flatten page annotations before using shrink-to-fit"). An exported PDF and
/// one saved with Save these pages as PDF (`file.printPdf`) keep them.
#[test]
fn only_the_print_job_leaves_out_link_annotations() {
let mut s = Session::new(wordcraft_doc::Document::new());
s.run("insert.link", &json!({"url": "https://example.com", "text": "a link"})).unwrap();
let lay = s.export_layout();
let exported = wordcraft_pdf::export_layout(&s.doc, &lay, &wordcraft_pdf::PdfOptions::default()).unwrap();
let links = |bytes: &[u8]| {
let raw = String::from_utf8_lossy(bytes);
raw.contains("/Annots") && raw.contains("/Link")
};
assert!(links(&exported), "an exported PDF keeps the link");
for params in [json!({}), json!({"paper": "A4"}), json!({"markup": true})] {
let (job, _) = s.print_job_pdf(&params).unwrap();
assert!(!links(&job) && !String::from_utf8_lossy(&job).contains("/Annots"), "{params}");
let (saved, _) = s.print_pdf(&params).unwrap();
assert!(links(&saved), "{params}");
}
#[cfg(not(target_arch = "wasm32"))]
{
let path = std::env::temp_dir().join(format!("wc-print-links-{}.pdf", std::process::id()));
s.run("file.printPdf", &json!({"path": path.to_string_lossy()})).unwrap();
let saved = std::fs::read(&path).unwrap();
let _ = std::fs::remove_file(&path);
assert!(links(&saved), "Save these pages as PDF keeps the link");
}
}
/// Scale to paper size (#2108): the PDF goes on the chosen paper; the document keeps its size.
#[test]
fn print_pdf_scales_to_the_chosen_paper() {
+59
View File
@@ -11475,3 +11475,62 @@ fn scale_font_sizes_reaches_char_table_and_cs_sizes_and_unset_default() {
assert_eq!(grid.header_chr.size, Some(16.0));
assert_eq!(grid.regions.get(&TablePart::Band2Horz).unwrap().chr.size, Some(10.0));
}
/// #3676: a 1-based page parameter becomes a 0-based index without wrapping.
/// On 32-bit and wasm the old cast truncated 2^32 to 0 and `0 - 1` panicked.
#[test]
fn page_index_saturates_instead_of_wrapping_to_page_one() {
assert_eq!(crate::p::page_index(0), 0);
assert_eq!(crate::p::page_index(1), 0);
assert_eq!(crate::p::page_index(2), 1);
assert_ne!(crate::p::page_index(1u64 << 32), 0, "2^32 must not wrap to page 1");
assert_eq!(crate::p::page_index(u64::MAX), usize::MAX - 1);
}
/// #3676: absolute page numbers that cannot be an index are rejected, not silently
/// turned into page 1. `edit.goto` clamps to the last page, as it does past the end.
#[test]
fn hostile_absolute_pages_never_land_on_page_one() {
let mut s = s();
for i in 0..5 {
if i > 0 {
run(&mut s, "insert.pageBreak", json!({}));
}
run(&mut s, "text.insert", json!({"text": format!("Page {}", i + 1)}));
}
let page = |s: &mut Session| s.layout().caret_on(&s.sel.focus, s.page_hint).unwrap().page + 1;
run(&mut s, "edit.goto", json!({"page": 1u64 << 32}));
assert_eq!(page(&mut s), 5, "an out-of-range page lands on the last page");
run(&mut s, "edit.goto", json!({"page": u64::MAX}));
assert_eq!(page(&mut s), 5, "u64::MAX lands on the last page");
run(&mut s, "edit.goto", json!({"page": 0}));
assert_eq!(page(&mut s), 1, "page 0 is the first page");
}
/// #3676: `caret.set` takes a 0-based page; an oversized page is rejected instead of
/// truncating to page 0 on 32-bit and wasm.
#[test]
fn caret_set_rejects_a_page_number_that_does_not_fit() {
let mut s = s();
run(&mut s, "text.insert", json!({"text": "Hello"}));
let r = s.run("caret.set", &json!({"page": 1u64 << 32, "x": 100.0, "y": 100.0}));
assert!(matches!(r, Err(crate::CmdError::Params(_))), "page 2^32: {r:?}");
}
/// #3676: `file.exportPng` rejects a page number that cannot be an index instead of
/// exporting page 1 (the 32-bit truncation) and writing it to the requested path.
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn export_png_rejects_a_page_number_that_does_not_fit() {
let dir = scratch_dir("export-png-hostile-page");
let mut s = s();
run(&mut s, "text.insert", json!({"text": "Hello"}));
let target = dir.join("page.png");
let r = s.run("file.exportPng", &json!({"path": target.to_string_lossy(), "page": 1u64 << 32}));
assert!(matches!(r, Err(crate::CmdError::Params(_))), "page 2^32: {r:?}");
assert!(!target.exists(), "no file is written for an invalid page");
let r = s.run("file.exportPng", &json!({"path": target.to_string_lossy(), "page": u64::MAX}));
assert!(matches!(r, Err(crate::CmdError::Params(_))), "page u64::MAX: {r:?}");
assert!(!target.exists(), "no file is written for an invalid page");
let _ = std::fs::remove_dir_all(&dir);
}
+12
View File
@@ -355,3 +355,15 @@ fn tools_address_an_open_document_by_id() {
assert_eq!(tool(&mut s, "get_text", json!({}))["text"].as_str().unwrap().trim(), "Second");
assert_eq!(tool(&mut s, "get_text", json!({"doc": first}))["text"].as_str().unwrap().trim(), "First more again");
}
/// #3676: a page number that cannot fit an index is rejected, not silently rendered as
/// page 1 (the old cast truncated 2^32 to 0 on 32-bit and wasm).
#[test]
fn render_page_rejects_a_page_number_that_does_not_fit() {
let mut s = Server::new(Box::new(Headless::default()));
tool(&mut s, "new_document", json!({}));
let r = call(&mut s, 30, "tools/call", json!({"name": "render_page", "arguments": {"page": 1u64 << 32, "scale": 0.5}}));
assert_eq!(r["result"]["isError"], true, "page 2^32: {r}");
let r = call(&mut s, 31, "tools/call", json!({"name": "render_page", "arguments": {"page": 1, "scale": 0.5}}));
assert_eq!(r["result"]["isError"], false, "page 1 still renders: {r}");
}
+4 -2
View File
@@ -104,8 +104,10 @@ fn write_attempt(doc: &Document, lay: &DocLayout, opts: &PdfOptions, pages: &[us
s.pop();
}
s.finish();
for a in ex.annotations(fit) {
kp.add_annotation(a);
if opts.links {
for a in ex.annotations(fit) {
kp.add_annotation(a);
}
}
kp.finish();
}
+5
View File
@@ -33,6 +33,10 @@ pub struct PdfOptions {
pub comments: bool,
/// Compress content streams.
pub compress: bool,
/// Write hyperlinks and in-document links as link annotations. A print job leaves them out:
/// they print nothing, and a printer driver can't fit a page with annotations to the paper
/// (#4734).
pub links: bool,
/// Print on this paper (width, height in points) instead of each page's own size: the page
/// is scaled to fit and centred, the paper turned to the page's orientation (Scale to paper
/// size, #2108). `None` keeps the document's page sizes.
@@ -52,6 +56,7 @@ impl Default for PdfOptions {
include_markup: false,
comments: false,
compress: true,
links: true,
paper: None,
numeral: NumeralMode::Arabic,
}
+2
View File
@@ -984,6 +984,8 @@ fn input_dialog_other(id: &str, params: &Value) -> Option<&'static str> {
"review.language" if no_settings(params) => Some("language"),
"tools.autocorrect" if no_settings(params) => Some("autoCorrect"),
"tools.templates" => Some("templates"),
// Macros without a name to run, define or delete shows its dialog (#4327); scripts get the list.
"tools.macros" if !["run", "define", "delete"].into_iter().any(|key| has_value(params, key)) => Some("macros"),
"styles.organizer" if !has_value(params, "path") => Some("organizer"),
"developer.properties" if no_settings(params) => Some("controlProperties"),
_ => None,
+67 -26
View File
@@ -21,6 +21,32 @@ const PAGES: [(&str, &str, &str); 11] = [
("options", "Options", "options"),
];
/// The Backstage pages' keytips, as Word's (#4960): Alt, F, then a letter. V is Word's older
/// Print Preview key, which opens the Print page too.
const KEYTIPS: [(&str, &str); 11] = [
("home", "H"),
("new", "N"),
("open", "O"),
("info", "I"),
("save", "S"),
("saveAs", "A"),
("print", "P"),
("print", "V"),
("export", "E"),
("close", "C"),
("options", "T"),
];
/// The page a Backstage keytip letter opens.
pub(crate) fn keytip_page(letter: &str) -> Option<&'static str> {
KEYTIPS.iter().find(|(_, l)| *l == letter).map(|(page, _)| *page)
}
/// The badge a Backstage page shows while its keytips do (the first letter listed).
fn keytip_letter(page: &str) -> Option<&'static str> {
KEYTIPS.iter().find(|(p, _)| *p == page).map(|(_, l)| *l)
}
/// The Backstage back chevron's centre on macOS (#1873): beside the traffic lights in a
/// window (the title bar's content edge), at the plain control inset in full screen, where the
/// lights aren't docked top-left and the reserved offset would leave dead space.
@@ -94,33 +120,14 @@ pub fn show(app: &mut WordApp, ui: &mut Ui) {
if active { semibold(14.0) } else { medium(14.0) },
ink,
);
if on
&& app.ui.keytips == crate::keytips::Phase::Backstage
&& let Some(letter) = keytip_letter(id)
{
crate::keytips::badge(ui, Rect::from_min_size(pos2(r.min.x + 16.0, r.min.y), vec2(20.0, 16.0)), letter);
}
if resp.clicked() {
match id {
// A document without a file goes to the Save As page (as in Word) instead
// of `file.save`, which would also open the native Save As dialog.
// In the browser a save is a download, so it saves right away.
"save" if app.session.path.is_none() && app.services.download.is_none() => {
app.ui.backstage_page = "saveAs".into();
}
"save" => {
let r = app.run("file.save", json!({}));
if r.is_ok_and(|v| v.get("saved").and_then(serde_json::Value::as_bool) == Some(true) || v.get("downloaded").is_some()) {
app.ui.backstage = false;
app.canvas.want_focus = true;
} else {
app.ui.backstage_page = "saveAs".into();
}
}
"saveAs" => {
app.ui.backstage_page = "saveAs".into();
}
// Not a page: `file.close` asks Save / Don't Save / Cancel first when there
// are unsaved changes, and Cancel leaves the Backstage where it was.
"close" => {
let _ = app.run("file.close", json!({}));
}
_ => app.ui.backstage_page = id.into(),
}
go_to_page(app, id);
}
}
ui.with_layout(egui::Layout::bottom_up(egui::Align::Min), |ui| {
@@ -214,6 +221,40 @@ fn recovery_page(app: &mut WordApp, ui: &mut Ui) {
});
}
/// Opens a side-menu page, as a click on it (or its keytip) does. Without a document only the
/// pages that work without one open.
pub(crate) fn go_to_page(app: &mut WordApp, id: &str) {
if !app.has_document() && !works_without_document(id) {
return;
}
match id {
// A document without a file goes to the Save As page (as in Word) instead
// of `file.save`, which would also open the native Save As dialog.
// In the browser a save is a download, so it saves right away.
"save" if app.session.path.is_none() && app.services.download.is_none() => {
app.ui.backstage_page = "saveAs".into();
}
"save" => {
let r = app.run("file.save", json!({}));
if r.is_ok_and(|v| v.get("saved").and_then(serde_json::Value::as_bool) == Some(true) || v.get("downloaded").is_some()) {
app.ui.backstage = false;
app.canvas.want_focus = true;
} else {
app.ui.backstage_page = "saveAs".into();
}
}
"saveAs" => {
app.ui.backstage_page = "saveAs".into();
}
// Not a page: `file.close` asks Save / Don't Save / Cancel first when there
// are unsaved changes, and Cancel leaves the Backstage where it was.
"close" => {
let _ = app.run("file.close", json!({}));
}
_ => app.ui.backstage_page = id.into(),
}
}
/// The Backstage pages that work while no document is open (#1129).
fn works_without_document(page: &str) -> bool {
matches!(page, "home" | "new" | "open" | "options")
+6
View File
@@ -278,6 +278,10 @@ pub enum Dialog {
/// The line the border choices draw.
pen: crate::dialogs_table_style::BorderPen,
},
/// View › Macros: the recorded macros to run or delete, and Record (#4327).
Macros {
name: String,
},
Commands {
query: String,
/// Opened by a shortcut that may also send its key's text (Alt+Q's "q", in the same frame
@@ -502,6 +506,7 @@ impl Dialog {
Dialog::TableStyle { id: None, .. } => "newTableStyle",
Dialog::TableStyle { .. } => "modifyTableStyle",
Dialog::Commands { .. } => "commands",
Dialog::Macros { .. } => "macros",
Dialog::Insert(d) => d.name(),
Dialog::Refs(d) => d.name(),
Dialog::Icons { .. } => "icons",
@@ -732,6 +737,7 @@ impl Dialog {
"manageStyles" => Dialog::ManageStyles { alphabetical: false, selected: s("style") },
"newTableStyle" | "modifyTableStyle" => crate::dialogs_table_style::open(app, name)?,
"commands" => Dialog::Commands { query: String::new(), swallow: true },
"macros" => Dialog::Macros { name: String::new() },
"icons" => Dialog::Icons { query: String::new(), category: String::new(), selected: String::new() },
"tableProperties" => {
let form = Box::new(TableForm::read(app)?);
+60
View File
@@ -198,3 +198,63 @@ pub(super) fn enclose_preview(ui: &mut Ui, style: &str, text: &str, shape: &str)
let dy = if shape == "triangle" && box_h > 0.0 { h * 0.3 } else { 0.0 };
p.text(c + vec2(0.0, dy), egui::Align2::CENTER_CENTER, text, egui::FontId::proportional(px), ink);
}
/// View › Macros (#4327): the macros recorded or defined this session, with Run and Delete beside
/// the list and Record below it. While a recording is running the box offers Stop Recording instead.
/// The list is read from the session, not from `tools.macros`, which would ask to open this
/// dialog again. Run and Record close the dialog; Delete leaves it open.
pub(super) fn macros(app: &mut WordApp, ui: &mut Ui, name: &mut String) -> bool {
let names: Vec<String> = app.session.macros.keys().cloned().collect();
let recording = app.session.recording.as_ref().map(|(n, _)| n.clone());
let t = Tokens::get(ui.ctx());
let (mut run, mut delete, mut record) = (false, false, false);
ui.horizontal_top(|ui| {
ui.vertical(|ui| {
let name_label = ui.label(tl!("Macro name:"));
ui.add(egui::TextEdit::singleline(name).desired_width(240.0)).labelled_by(name_label.id);
egui::Frame::NONE.stroke(egui::Stroke::new(1.0, t.border)).inner_margin(4).show(ui, |ui| {
ui.set_width(232.0);
ui.set_height(150.0);
egui::ScrollArea::vertical().id_salt("macro_list").max_height(150.0).auto_shrink([false, false]).show(ui, |ui| {
if names.is_empty() {
ui.label(egui::RichText::new(tl!("There are no macros yet. Record one to add it here.")).small().color(t.text_dim));
}
for n in &names {
if ui.selectable_label(*n == *name, n.as_str()).clicked() {
*name = n.clone();
}
}
});
});
});
ui.vertical(|ui| {
ui.add_space(18.0);
let listed = names.contains(name);
let w = vec2(110.0, 0.0);
run = ui.add_enabled(listed && recording.is_none(), egui::Button::new(tl!("Run")).min_size(w)).clicked();
delete = ui.add_enabled(listed, egui::Button::new(tl!("Delete")).min_size(w)).clicked();
let record_label = if recording.is_some() { tl!("Stop Recording") } else { tl!("Record…") };
record = ui.add_enabled(recording.is_some() || !name.trim().is_empty(), egui::Button::new(record_label).min_size(w)).clicked();
});
});
if run {
let _ = app.run("tools.macros", json!({"run": name.as_str()}));
return true;
}
if delete && app.run("tools.macros", json!({"delete": name.as_str()})).is_ok() {
name.clear();
}
if record {
// Stopping takes no name; starting records under the one typed.
let _ = app.run("tools.recordMacro", if recording.is_some() { json!({}) } else { json!({"name": name.trim()}) });
return true;
}
ui.add_space(8.0);
let mut close = ui.input(|i| i.key_pressed(egui::Key::Escape));
ui.horizontal(|ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
close |= ui.button(tl!("Close")).clicked();
});
});
close
}
+1
View File
@@ -106,6 +106,7 @@ pub fn show(app: &mut WordApp, ctx: &egui::Context) {
Dialog::TableStyle { id: None, .. } => "New Table Style",
Dialog::TableStyle { .. } => "Modify Table Style",
Dialog::Commands { .. } => "Search Commands",
Dialog::Macros { .. } => "Macros",
Dialog::Insert(d) => d.title(),
Dialog::Refs(d) => d.title(),
Dialog::Icons { .. } => "Icons",
+2 -1
View File
@@ -1,4 +1,4 @@
use super::bookmarks::{bookmark, enclose_preview, icons_body};
use super::bookmarks::{bookmark, enclose_preview, icons_body, macros};
use super::chrome::{buttons, color_field};
use super::find::{FindTab, SEARCH_SUGGESTIONS, command_matches, find_in_navigation_pane, goto_body, special_menu, swallow_shortcut_text};
use super::font::{apply_font, preview_size};
@@ -36,6 +36,7 @@ pub(super) fn body(app: &mut WordApp, ui: &mut Ui, d: &mut Dialog) -> bool {
Dialog::Insert(f) => crate::dialogs_insert::body(app, ui, f),
Dialog::Refs(f) => crate::dialogs_refs::body(app, ui, f),
Dialog::Commands { .. } => commands_dialog(app, ui, d),
Dialog::Macros { name } => macros(app, ui, name),
Dialog::Icons { query, category, selected } => icons_body(app, ui, query, category, selected),
Dialog::PasteSpecial { .. } => paste_special_dialog(app, ui, d),
Dialog::About { .. } => about_dialog(ui, d),
+61
View File
@@ -144,6 +144,67 @@ fn find_replace_and_go_to_are_one_dialog() {
}
}
/// #4327: View › Macros opens a dialog that runs, deletes and records macros; the command with
/// a name to run or delete (what scripts send) still acts without one.
#[test]
fn the_macros_button_opens_a_dialog_that_runs_deletes_and_records() {
fn press(h: &mut egui_kittest::Harness<'_, WordApp>, label: &str) {
use egui_kittest::kittest::Queryable;
let dialog = h.ctx.memory(|m| m.area_rect(egui::Id::unique(("dialog", "Macros")))).expect("the dialog is open");
h.query_all_by_label(label).find(|n| dialog.contains(n.rect().center())).expect(label).click();
for _ in 0..3 {
h.step();
}
}
let mut app = app_with("Start");
for name in ["Greet", "Spare"] {
app.run("tools.macros", json!({"define": {"name": name, "steps": [{"command": "text.insert", "params": {"text": name}}]}})).unwrap();
}
assert!(app.dialog.is_none(), "defining a macro opens nothing");
assert_eq!(app.run("tools.macros", json!({})).unwrap(), json!({"pending": "macros"}));
let mut h = app_harness(app);
h.run_steps(4);
assert!(matches!(&h.state().dialog, Some(Dialog::Macros { .. })));
press(&mut h, "Spare");
press(&mut h, "Delete");
let names: Vec<&String> = h.state().session.macros.keys().collect();
assert_eq!(names, ["Greet"]);
assert!(h.state().dialog.is_some(), "Delete leaves the dialog open");
press(&mut h, "Greet");
press(&mut h, "Run");
assert!(h.state().dialog.is_none());
assert!(body_of(h.state()).contains("Greet"), "the macro ran");
// A macro whose name has spaces around it (only a script can make one) runs by its exact name.
h.state_mut()
.run("tools.macros", json!({"define": {"name": " Pad ", "steps": [{"command": "text.insert", "params": {"text": "Padded"}}]}}))
.unwrap();
h.state_mut().dialog = Dialog::open("macros", h.state_mut());
if let Some(Dialog::Macros { name }) = &mut h.state_mut().dialog {
*name = " Pad ".into();
}
h.run_steps(3);
press(&mut h, "Run");
assert!(h.state().dialog.is_none());
assert!(body_of(h.state()).contains("Padded"), "the macro with spaces in its name ran");
// Record starts a recording under the typed name; the dialog then offers to stop it.
h.state_mut().dialog = Dialog::open("macros", h.state_mut());
if let Some(Dialog::Macros { name }) = &mut h.state_mut().dialog {
*name = "Fresh".into();
}
h.run_steps(3);
press(&mut h, "Record…");
assert_eq!(h.state().session.recording.as_ref().map(|(n, _)| n.as_str()), Some("Fresh"));
assert!(h.state().dialog.is_none());
}
fn body_of(app: &WordApp) -> String {
app.session.doc.plain_text(wordcraft_doc::StoryRef::Body)
}
fn app_with(text: &str) -> WordApp {
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
let _ = app.run("document.setText", json!({"text": text}));
+18 -5
View File
@@ -42,6 +42,8 @@ pub enum Phase {
/// Partway through a legacy menu key sequence (#1697); the letters so far are in
/// `keytip_prefix`, and a hint stands in for the badges.
Legacy,
/// Badges over the Backstage side menu, after Alt, F (#4960).
Backstage,
}
/// Which ribbon item a letter is bound to, and what pressing it does.
@@ -602,8 +604,8 @@ pub fn handle_key(app: &mut WordApp, key: egui::Key) -> bool {
match hit {
Some(tab) => {
let _ = app.run("ui.tab", serde_json::json!({ "tab": tab }));
// File opens the Backstage: no ribbon commands to badge.
app.ui.keytips = if tab == "File" { Phase::Off } else { Phase::Commands };
// File opens the Backstage: its pages get the badges (Alt, F, P prints).
app.ui.keytips = if tab == "File" && app.ui.backstage { Phase::Backstage } else { Phase::Commands };
}
// Q is the title bar's Search box, as in Word (#819).
None if name == SEARCH_LETTER => {
@@ -622,6 +624,12 @@ pub fn handle_key(app: &mut WordApp, key: egui::Key) -> bool {
legacy_key(app, &name);
return true;
}
Phase::Backstage => {
app.ui.keytips = Phase::Off;
if let Some(page) = crate::backstage::keytip_page(&name) {
crate::backstage::go_to_page(app, page);
}
}
Phase::Commands => {
let tab = app.ui.tab.clone();
let ls = letters_for(app, &tab);
@@ -694,11 +702,16 @@ pub fn activate(app: &mut WordApp) {
use crate::keys;
/// Keytips are suppressed while the Backstage or a modal dialog is open, or while a text field
/// Keytips are suppressed while the Backstage (except for its own badges, Alt, F) or a modal dialog is open, or while a text field
/// (not the canvas) has focus; the canvas lets Alt open keytips and `canvas_events` swallows
/// typing while they show.
/// typing while they show. The Backstage's badges end with it (its back chevron, a mouse Save),
/// so the next letter is typed and never picks a page that is no longer there.
pub fn suppressed(app: &WordApp, ctx: &egui::Context) -> bool {
!app.ui.keytips_enabled || app.ui.backstage || app.dialog.is_some() || (ctx.egui_wants_keyboard_input() && !app.canvas.focused)
!app.ui.keytips_enabled
|| (app.ui.backstage && app.ui.keytips != Phase::Backstage)
|| (!app.ui.backstage && app.ui.keytips == Phase::Backstage)
|| app.dialog.is_some()
|| (ctx.egui_wants_keyboard_input() && !app.canvas.focused)
}
/// Native backends report Alt through both key and modifier events, in either order. Track
+84 -2
View File
@@ -300,12 +300,13 @@ fn keytip_state_machine() {
assert_eq!(a.ui.keytips, Phase::Commands);
assert!(handle_key(&mut a, egui::Key::F));
assert_eq!(a.ui.keytips, Phase::Off);
// Alt, F: the Backstage, and keytips end.
// Alt, F: the Backstage, with its pages' keytips (#4960).
a.ui.backstage = false;
activate(&mut a);
assert!(handle_key(&mut a, egui::Key::F));
assert!(a.ui.backstage, "Alt, F opens File");
assert_eq!(a.ui.keytips, Phase::Off);
assert_eq!(a.ui.keytips, Phase::Backstage);
a.ui.keytips = Phase::Off;
// Alt, W: View; Alt, R: Review (Word's letters, not V and S).
a.ui.backstage = false;
activate(&mut a);
@@ -541,3 +542,84 @@ fn alt_then_q_opens_search() {
assert_eq!(a.ui.keytips, Phase::Off);
assert!(matches!(a.dialog, Some(crate::dialogs::Dialog::Commands { .. })), "{:?}", a.dialog.as_ref().map(|d| d.name()));
}
/// #4960: Alt, F opens the Backstage with badges on its pages, as in Word; Alt, F, P and Word's
/// older Alt, F, V open the Print page (Print Preview). Typed through `logic`, the path real
/// keys take, which keytips used to leave as soon as the Backstage opened.
#[test]
fn file_keytips_reach_the_backstage_pages() {
let ctx = egui::Context::default();
let tap = |ctx: &egui::Context, a: &mut WordApp| {
input_frame(ctx, a, vec![key_event(egui::Key::AltLeft, true, egui::Modifiers::ALT)]);
input_frame(ctx, a, vec![key_event(egui::Key::AltLeft, false, egui::Modifiers::NONE)]);
};
let letter = |ctx: &egui::Context, a: &mut WordApp, k: egui::Key| {
input_frame(ctx, a, vec![key_event(k, true, egui::Modifiers::NONE), key_event(k, false, egui::Modifiers::NONE)]);
};
for (second, page) in [(egui::Key::P, "print"), (egui::Key::V, "print"), (egui::Key::A, "saveAs"), (egui::Key::T, "options")] {
let mut a = app();
if cfg!(target_os = "macos") {
activate(&mut a);
} else {
tap(&ctx, &mut a);
}
assert_eq!(a.ui.keytips, Phase::Tabs);
letter(&ctx, &mut a, egui::Key::F);
assert!(a.ui.backstage, "F opens the Backstage");
assert_eq!(a.ui.keytips, Phase::Backstage, "and its pages show badges");
input_frame(&ctx, &mut a, vec![]);
assert_eq!(a.ui.keytips, Phase::Backstage, "the badges stay while it waits");
letter(&ctx, &mut a, second);
assert_eq!((a.ui.backstage, a.ui.backstage_page.as_str()), (true, page), "{second:?}");
assert_eq!(a.ui.keytips, Phase::Off);
}
// A letter with no page ends the badges and leaves the Backstage open; Esc too.
for k in [egui::Key::Q, egui::Key::Escape] {
let mut a = app();
activate(&mut a);
letter(&ctx, &mut a, egui::Key::F);
let page = a.ui.backstage_page.clone();
letter(&ctx, &mut a, k);
assert_eq!((a.ui.keytips, a.ui.backstage, a.ui.backstage_page.clone()), (Phase::Off, true, page), "{k:?}");
}
assert_eq!(crate::backstage::keytip_page("P"), Some("print"));
assert_eq!(crate::backstage::keytip_page("V"), Some("print"));
assert_eq!(crate::backstage::keytip_page("R"), None);
}
/// #4981 review: the Backstage closed while its badges show (the back chevron, a mouse Save)
/// ends them. The next letter is typed, and never picks a page with the Backstage gone: C used
/// to close the document and S to save it.
#[test]
fn closing_the_backstage_ends_its_keytips() {
let mut a = app();
a.canvas.focused = true;
a.canvas.want_focus = true;
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
h.run_steps(4);
let key = |key| key_event(key, true, egui::Modifiers::NONE);
h.input_mut().events.push(key(egui::Key::F10));
h.step();
assert_eq!(h.state().ui.keytips, Phase::Tabs);
h.input_mut().events.extend([key(egui::Key::F), egui::Event::Text("f".into())]);
h.step();
assert_eq!((h.state().ui.backstage, h.state().ui.keytips), (true, Phase::Backstage));
// What the back chevron does.
h.state_mut().ui.backstage = false;
h.state_mut().canvas.want_focus = true;
h.run_steps(2);
assert_eq!(h.state().ui.keytips, Phase::Off, "the badges end with the Backstage");
h.input_mut().events.extend([key(egui::Key::C), egui::Event::Text("c".into())]);
h.run_steps(2);
assert_eq!(h.state().ui.keytips, Phase::Off);
assert!(h.state().has_document(), "C does not close the document");
assert!(!h.state().ui.backstage);
assert_eq!(h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body).trim(), "c", "C is typed");
}
+1 -1
View File
@@ -175,7 +175,7 @@ pub fn submit(app: &mut crate::WordApp, params: &serde_json::Value) -> Result<se
}
let colour = if app.ui.print_backgrounds { None } else { app.session.doc.settings.page_color.take() };
let picture = if app.ui.print_backgrounds { None } else { app.session.doc.settings.page_picture.take() };
let pdf = app.session.print_pdf(&pdf_params).map_err(|error| error.to_string());
let pdf = app.session.print_job_pdf(&pdf_params).map_err(|error| error.to_string());
if colour.is_some() {
app.session.doc.settings.page_color = colour;
}
+25 -1
View File
@@ -210,7 +210,7 @@ fn native_ranges_and_parity_do_not_duplicate_spooler_copies() {
}
assert!(jobs.borrow().is_empty(), "invalid settings do not send any job");
let params = json!({"pages":"1-3","parity":"odd","collate":false});
let (expected, plan) = app.session.print_pdf(&params).unwrap();
let (expected, plan) = app.session.print_job_pdf(&params).unwrap();
assert_eq!(plan.pages, vec![0, 2]);
app.run("ui.printSubmit", params).unwrap();
let jobs = jobs.borrow();
@@ -308,3 +308,27 @@ fn native_print_scales_to_the_chosen_paper() {
assert_eq!(jobs.borrow().len(), before);
assert_eq!((app.session.doc.last_section.page_w, app.session.doc.last_section.page_h), page, "the document is unchanged");
}
/// #4734: the job sent to the printer has no link annotations, which a printer driver can't fit
/// to the paper ("flatten page annotations before using shrink-to-fit"); `file.printPdf` (Save
/// these pages as PDF) keeps them.
#[test]
fn native_print_job_leaves_out_link_annotations() {
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), Services::default());
app.run("insert.link", json!({"url": "https://example.com", "text": "a link"})).unwrap();
app.printing.printers.push(Printer { name: "Queue".into(), label: String::new(), default: true });
app.run("ui.printSettings", json!({"printer":"Queue"})).unwrap();
let jobs = Rc::new(RefCell::new(Vec::new()));
let observed = jobs.clone();
app.services.print_native = Some(Box::new(move |bytes, _, _, _| {
observed.borrow_mut().push(bytes);
let (sender, receiver) = std::sync::mpsc::channel();
sender.send(Ok("queued".into())).unwrap();
receiver
}));
let annots = |bytes: &[u8]| String::from_utf8_lossy(bytes).contains("/Annots");
app.run("ui.printSubmit", json!({"paper": "A4"})).unwrap();
assert!(!annots(&jobs.borrow()[0]), "the printer gets no link annotations");
let (saved, _) = app.session.print_pdf(&json!({"paper": "A4"})).unwrap();
assert!(annots(&saved), "a saved print PDF keeps its links");
}
+3 -1
View File
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -1,6 +1,6 @@
# Hardware parity with Microsoft Word
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-15 · **Change:** trivial (Pen / stylus row: two-stroke and closed-head arrows; previously trivial: Pen / stylus row: ink, eraser and Ink to Shape incl. arrows landed; previously trivial: a window too big for its screen shrinks to fit when it opens, #1215; previously trivial: 32-bit Windows starts on OpenGL; previously major: first version) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 and Word for Windows
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-30 · **Change:** trivial (only the PDF sent to the printer has no link annotations; Save these pages as PDF keeps them, #4734); previously trivial (a document with links prints: the print job's PDF has no link annotations, #4734; previously trivial: Pen / stylus row: two-stroke and closed-head arrows; previously trivial: Pen / stylus row: ink, eraser and Ink to Shape incl. arrows landed; previously trivial: a window too big for its screen shrinks to fit when it opens, #1215; previously trivial: 32-bit Windows starts on OpenGL; previously major: first version) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4 and Word for Windows
> **Printing update:** 2026-10-12 · direct desktop printing through craft-print; details below.
@@ -12,7 +12,7 @@ pens, microphones (Dictate) and speakers (Read Aloud), and displays.
| Hardware | Word | WordCraft macOS | Windows | Linux / BSD | Web | Parity | Hours |
|---|---|---|---|---|---|---|---|
| Printers: native print dialog, printer choice, copies, duplex, page ranges, tray, scaling | ✅ (`WordPDE.plugin` print-dialog extension on Mac) | 🟡 Direct CUPS printing; printer, copies, collation, duplex, ranges, grayscale and scale to paper size | 🟡 Direct spooler printing; printer, copies, collation, duplex, ranges, grayscale and scale to paper size | 🟡 Direct spooler printing; printer, copies, collation, duplex, ranges, grayscale and scale to paper size | ✅ browser print dialog (#209) | 35% | 5–8 |
| Printers: native print dialog, printer choice, copies, duplex, page ranges, tray, scaling | ✅ (`WordPDE.plugin` print-dialog extension on Mac) | 🟡 Direct CUPS printing; printer, copies, collation, duplex, ranges, grayscale and scale to paper size; on every desktop the PDF sent to the printer leaves out link annotations, which the spooler can't fit to the paper; Save these pages as PDF keeps them (#4734) | 🟡 Direct spooler printing; printer, copies, collation, duplex, ranges, grayscale and scale to paper size; on every desktop the PDF sent to the printer leaves out link annotations, which the spooler can't fit to the paper; Save these pages as PDF keeps them (#4734) | 🟡 Direct spooler printing; printer, copies, collation, duplex, ranges, grayscale and scale to paper size; on every desktop the PDF sent to the printer leaves out link annotations, which the spooler can't fit to the paper; Save these pages as PDF keeps them (#4734) | ✅ browser print dialog (#209) | 35% | 5–8 |
| GPU rendering, HiDPI/Retina, pixel-aligned text | ✅ | ✅ wgpu + vello_cpu rasteriser, whole-pixel text (#110, #165) | ✅ DirectX 12 default (#50), OpenGL when DirectX 12 has no GPU driver (#316) or on 32-bit; startup crash on Intel UHD (#170) | ✅ (soft text on KDE at some zooms, #140) | ✅ | 80% | 3–5 (bugs) |
| Pen / stylus: ink, pressure, eraser, ink to shape/math | ✅ (Draw tab, `InkRender.bundle`) | 🟡 ink, stroke eraser, Ink to Shape incl. one- and two-stroke arrows with open or closed heads (#307, #395); pressure and Ink to Math missing | 🟡 same | 🟡 same | 🟡 same | 50% | (Draw tab, 15–25) |
| Multiple monitors, per-monitor DPI, remembered window position, a window that fits its screen | ✅ | ✅ (#38, #76, #1215) | ✅ (winit DPI fix pending, #155) | ✅ | — | 85% | 1 |
@@ -25,6 +25,8 @@ pens, microphones (Dictate) and speakers (Read Aloud), and displays.
| Date | Change | Summary |
|---|---|---|
| 2026-10-30 | trivial | Only the PDF sent to the printer leaves out link annotations; Save these pages as PDF (`file.printPdf`) keeps them (#4734) |
| 2026-10-29 | trivial | A document with links prints: the print job's PDF leaves out link annotations, which the spooler refused to fit to the paper (#4734) |
| 2026-10-15 | trivial | Pen / stylus row: Ink to Shape also makes two-stroke arrows and arrows with a closed triangle head |
| 2026-10-17 | minor | File › Print's Scale to paper size (#2108): pick Letter, Legal, A4 or any Layout › Size paper and every page is scaled to it and centred, the paper turned to each page's orientation, in the preview, the print job (with the spooler's media) and Save these pages as PDF; the document keeps its page size. `paper` param on `ui.print`/`file.printPdf` |
| 2026-10-14 | trivial | Pen / stylus row corrected: ink, eraser and Ink to Shape (with arrows) work; pressure and Ink to Math missing |
+4 -3
View File
@@ -1,6 +1,6 @@
# Localization parity with Microsoft Word
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-28 · **Change:** trivial (the Traditional Chinese interface draws hanzi to the Taiwan standard with an installed Traditional Chinese font first: PingFang TC, Microsoft JhengHei, Noto Sans CJK TC; previously minor: the egui 0.37 migration preserves the equation “Delete Around Caret in Equation” translation in all 27 catalogs through the shared catalog pin; previously minor: Spanish proofing: es-ES, es-MX, es-419 and es-UY from the installed Hunspell dictionaries, Uruguayan `vos` forms, opening `¿`/`¡` checks, #3360, #3553; previously minor: the interface catalogs moved to storytold/craft-i18n and are looked up through the `craft-i18n` crate, embedded at build time from the commit in `craft-i18n.rev`; previously trivial: interface-language tests: a missing translation never fails a test, `cargo xtask i18n-report` in `cargo xtask ci` prints the strings each language lacks, and lookup and template tests use inline fixture catalogs or the pseudo-language; previously trivial: interface audit: missing catalog entries are reported per language and don't fail the audit; previously minor: disabled-control reasons in ribbon hints translated in every catalog, #2678; previously trivial: Slovenian interface catalog: every key of every other catalog, 2,614 entries; previously minor: Romanian interface catalog; previously trivial: the File › Home greeting is translated in every catalog; previously trivial: Japanese row: ruby (Phonetic Guide) is supported and HTML export/import keeps it, #1681; previously trivial: Russian sorting keeps ё with е and recognises decomposed ё/й; previously minor: English dialects: en-GB, en-CA, en-AU and the other British-spelling Englishes proof their own spellings and flag the other dialect's, #1281, #1045; previously minor: how to install the Hunspell dictionaries on Windows, macOS and Linux: `docs/spelling-dictionaries.md`; previously minor: Read Aloud speaks each sentence in its own language, #1843; previously minor: Indonesian proofing: id-ID spelling from the installed Hunspell dictionary, dictionary-driven suggestions, generic checks with Indonesian messages, #498; previously trivial: print-area strings translated in every catalog; previously trivial: Italian: the interface audit checks the Italian catalog, `Privacy Settings` wording; previously trivial: Italian grammar: `po'`, `qual è`, `È`, `un`/`un'` rules; more elisions and truncations in spelling; previously trivial: Czech interface catalog completed, 2,447 entries; previously trivial: interface audit runs in CI again: size labels translated, 20 strings in every catalog, Read Aloud error race fixed, #1128; previously trivial: Review › Language reaches every language again — Set Proofing Language… and Set As Default, #860; previously minor: Italian proofing: it-IT spelling from the installed Hunspell dictionary, accent-first suggestions, conservative grammar with Italian messages; previously minor: Portuguese proofing; previously trivial: Turkish interface catalog completed, 2,325 entries, #774; previously minor: Hungarian interface added; previously trivial: sorting and table numbers follow the text's language, #836, #837; previously minor: Polish interface; Polish proofing — spelling, grammar, hyphenation — and a proofing language per run; previously minor: Turkish interface added; previously major: first version; catalogs measured from `crates/ui-egui/src/i18n`, Word's languages from its bundle listing) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** trivial (word count counts each Han ideograph and kana as a word, #4547; previously trivial: the Traditional Chinese interface draws hanzi to the Taiwan standard with an installed Traditional Chinese font first: PingFang TC, Microsoft JhengHei, Noto Sans CJK TC; previously minor: the egui 0.37 migration preserves the equation “Delete Around Caret in Equation” translation in all 27 catalogs through the shared catalog pin; previously minor: Spanish proofing: es-ES, es-MX, es-419 and es-UY from the installed Hunspell dictionaries, Uruguayan `vos` forms, opening `¿`/`¡` checks, #3360, #3553; previously minor: the interface catalogs moved to storytold/craft-i18n and are looked up through the `craft-i18n` crate, embedded at build time from the commit in `craft-i18n.rev`; previously trivial: interface-language tests: a missing translation never fails a test, `cargo xtask i18n-report` in `cargo xtask ci` prints the strings each language lacks, and lookup and template tests use inline fixture catalogs or the pseudo-language; previously trivial: interface audit: missing catalog entries are reported per language and don't fail the audit; previously minor: disabled-control reasons in ribbon hints translated in every catalog, #2678; previously trivial: Slovenian interface catalog: every key of every other catalog, 2,614 entries; previously minor: Romanian interface catalog; previously trivial: the File › Home greeting is translated in every catalog; previously trivial: Japanese row: ruby (Phonetic Guide) is supported and HTML export/import keeps it, #1681; previously trivial: Russian sorting keeps ё with е and recognises decomposed ё/й; previously minor: English dialects: en-GB, en-CA, en-AU and the other British-spelling Englishes proof their own spellings and flag the other dialect's, #1281, #1045; previously minor: how to install the Hunspell dictionaries on Windows, macOS and Linux: `docs/spelling-dictionaries.md`; previously minor: Read Aloud speaks each sentence in its own language, #1843; previously minor: Indonesian proofing: id-ID spelling from the installed Hunspell dictionary, dictionary-driven suggestions, generic checks with Indonesian messages, #498; previously trivial: print-area strings translated in every catalog; previously trivial: Italian: the interface audit checks the Italian catalog, `Privacy Settings` wording; previously trivial: Italian grammar: `po'`, `qual è`, `È`, `un`/`un'` rules; more elisions and truncations in spelling; previously trivial: Czech interface catalog completed, 2,447 entries; previously trivial: interface audit runs in CI again: size labels translated, 20 strings in every catalog, Read Aloud error race fixed, #1128; previously trivial: Review › Language reaches every language again — Set Proofing Language… and Set As Default, #860; previously minor: Italian proofing: it-IT spelling from the installed Hunspell dictionary, accent-first suggestions, conservative grammar with Italian messages; previously minor: Portuguese proofing; previously trivial: Turkish interface catalog completed, 2,325 entries, #774; previously minor: Hungarian interface added; previously trivial: sorting and table numbers follow the text's language, #836, #837; previously minor: Polish interface; Polish proofing — spelling, grammar, hyphenation — and a proofing language per run; previously minor: Turkish interface added; previously major: first version; catalogs measured from `crates/ui-egui/src/i18n`, Word's languages from its bundle listing) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4
Interface languages, script support and proofing per language. How translation works (adding a
language, the embedded catalogs): `crates/ui-egui/src/i18n.rs`. The catalogs, their format and
@@ -58,14 +58,14 @@ shared items below.
| Language | Code | UI strings translated | Dialogs / tooltips / help | Script support | Native review | Status | Hours to full |
|---|---|---|---|---|---|---|---|
| English | en | source (100%) | ✅ | Latin ✅ | yes | **full** | 0 |
| Simplified Chinese (Mandarin) | zh-hans | 929 entries; 98% of extracted, ~95% of visible | most; newer panes English | CJK ✅, IME ✅; Windows UI font fixed (#248); interface font chain covers every catalog character, installed CJK font after the embedded ones when it doesn't, PingFang found on macOS 12 (#486); font list by Chinese names (宋体, 微软雅黑, #505); no vertical text | no | partial | 3–5 |
| Simplified Chinese (Mandarin) | zh-hans | 929 entries; 98% of extracted, ~95% of visible | most; newer panes English | CJK ✅, IME ✅; Windows UI font fixed (#248); interface font chain covers every catalog character, installed CJK font after the embedded ones when it doesn't, PingFang found on macOS 12 (#486); font list by Chinese names (宋体, 微软雅黑, #505); word count counts each Han ideograph and kana as a word, not punctuation (#4547); no vertical text | no | partial | 3–5 |
| Spanish | es | ~930; 98% / ~95% | most | Latin ✅ | no | partial | 1–2 |
| Hindi | hi | 0 | ❌ | Devanagari shaping via HarfRust, untested; no hyphenation | no | none | 4–6 |
| Arabic | ar | 0 | ❌ | shaping, joining, lam-alef, bidi ✅ (#207); no kashida; **no mirrored UI** | no | none | 6–8 |
| French | fr | 2,615 entries (complete catalog) | all | Latin ✅ | no | partial (no proofing) | 1–2 (proofing) |
| Portuguese | pt-br (pt-PT none) | ~930; 98% / ~95% (pt-BR) | most | Latin ✅ | no | partial | 2–4 (pt-BR finish + pt-PT) |
| Indonesian | id | 0 | ❌ | Latin ✅ | no | none | 3–4 |
| Japanese | ja | ~930; 98% / ~95% | most | CJK ✅, IME ✅; ruby (Phonetic Guide) over its base text, kept by HTML export/import (#1681); no vertical text or document grid | no | partial | 3–5 |
| Japanese | ja | ~930; 98% / ~95% | most | CJK ✅, IME ✅; ruby (Phonetic Guide) over its base text, kept by HTML export/import (#1681); word count counts each Han ideograph and kana as a word, not punctuation (#4547); no vertical text or document grid | no | partial | 3–5 |
| German | de | 2,021 entries; same key set as zh-hans (#574); 98% of extracted, ~95% of visible | most | Latin ✅ | no | partial | 1–2 |
| Korean | ko | 2,463 entries (all catalog keys and preview context) | most; newer panes English | Hangul ✅ (Korean-first embedded/system UI font fallback); macOS Korean IME fixes pending (#163, #164) | no | partial | 3–5 |
| Vietnamese | vi | 2,448 entries; every key of the reference catalogs (#1434); 98% of extracted, ~95% of visible | most | Latin ✅ | no | partial | 0–1 (review) |
@@ -285,3 +285,4 @@ WordCraft keeps 2,54 cm).
| 2026-10-10 | minor | Serbian (Cyrillic and Latin) interface merged (#250) |
| 2026-10-10 | major | First version: twelve-language table, catalog coverage measured, Word's 30 UI languages and 120 proofing tools listed |
| 2026-10-17 | trivial | Ribbon hints' disabled-control reasons (28 strings such as `select a chart first`, `only in Outline view`) translated in all 22 catalogs, machine-written from the English meaning and pending native-speaker review; a test reads the reasons from the engine's command sources and requires every catalog to have them (#2678) |
| 2026-10-28 | trivial | Word count counts each Han ideograph and kana as a word, as Word does, so unspaced Chinese and Japanese text is no longer one word per run; Hangul still counts by spaced words (#4547) |
+4 -2
View File
File diff suppressed because one or more lines are too long