Type: Smart Punctuation replaces ligatures, extra spaces and fractions and reports results

Type > Smart Punctuation... now opens its own dialog in place of the
generic parameter form. It has the seven replacement options, Replace In
(Selected Text Only or Entire Document) and Report Results, which lists
how many of each chosen replacement were made after OK. The dialog opens
on the options confirmed last.

- type.smartPunctuation takes fiLigatures, flLigatures, spaces and
  fractions, all off by default, so existing calls behave as before.
- Ligatures write U+FB00 to U+FB04, longest match first. Expert
  Fractions writes the one-character fractions Unicode encodes, and
  skips one with a digit, a slash or a decimal point next to it, across
  a change of style too. Either is written only where the run's font
  has a glyph for it.
- Smart Spaces keeps one space after a period, across runs. An inline
  graphic separates the text on either side of it.
- The reply adds a replaced object with a count per kind. Nothing to
  replace still records no undo step.

Docs: docs/mcp.md, docs/type-parity.md.
This commit is contained in:
dotCooCoo committed 2026-11-14 11:09:09 -08:00
1 parent 67f6d3a50f
commit 1bd269b4ed
39 files changed
+930 -26

No files matched your search

+271 -18
View File
@@ -30,7 +30,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Smart Punctuation…",
["Type"],
None,
"{quotes?: true (straight quotes become the Document Setup quotes), dashes?: true (-- → en dash, --- → em dash), ellipsis?: true (... → …), scope?: \"selection\"|\"document\"} → {changed}",
"{fiLigatures?: false (ff, fi, ffi → the ligatures U+FB00, U+FB01, U+FB03), flLigatures?: false (ff, fl, ffl → U+FB00, U+FB02, U+FB04), quotes?: true (straight quotes become the Document Setup quotes), spaces?: false (two or more spaces after a period → one), dashes?: true (-- → en dash, --- → em dash), ellipsis?: true (... → …), fractions?: false (1/2, 1/4, 3/4 and the other fractions Unicode encodes as one character, with no digit, slash or decimal point next to them, → ½, ¼, ¾ …), scope?: \"selection\"|\"document\"} the selected type, or every text object with scope document or nothing selected; a ligature or a fraction is written only where the run's font has a glyph for it. Nothing to replace records no undo step → {changed: text objects changed, replaced: {fiLigatures, flLigatures, quotes, spaces, dashes, ellipses, fractions}: how many of each were replaced}",
has_doc,
smart_punctuation
),
@@ -268,24 +268,226 @@ fn change_case(s: &mut Session, p: &Value) -> Result<Value> {
// ---------- Smart Punctuation ----------
#[derive(Default)]
struct PunctState {
prev: Option<char>,
/// What Smart Punctuation replaces: each option of its dialog.
struct Punct {
/// ff, fi and ffi become the ligatures U+FB00, U+FB01 and U+FB03.
fi_ligatures: bool,
/// ff, fl and ffl become the ligatures U+FB00, U+FB02 and U+FB04.
fl_ligatures: bool,
/// Straight quotes become these quotes (the Document Setup quotes).
quotes: Option<Quotes>,
/// Two or more spaces after a period become one.
spaces: bool,
/// `--` becomes an en dash and `---` an em dash.
dashes: bool,
/// `...` becomes an ellipsis.
ellipses: bool,
/// `1/2` and the other fractions [`FRACTIONS`] lists become their one-character forms.
fractions: bool,
}
/// Dashes (`--` en, `---` em), ellipses and, with `quotes`, typographer's quotes.
pub(crate) fn smarten(text: &str, prev: &mut Option<char>, quotes: Option<&Quotes>, dashes: bool, ellipsis: bool) -> String {
let mut s = text.to_string();
if dashes {
s = s.replace("---", "—").replace("--", "–");
/// How many of each replacement Smart Punctuation made.
#[derive(Default)]
struct PunctCounts {
fi_ligatures: usize,
fl_ligatures: usize,
quotes: usize,
spaces: usize,
dashes: usize,
ellipses: usize,
fractions: usize,
}
/// The text before the run being rewritten, across the runs of one text object.
#[derive(Default)]
struct PunctState {
/// The character before the run.
prev: Option<char>,
/// The number of spaces since the last period, while only spaces follow it.
after_period: Option<usize>,
/// An inline graphic comes right before the run.
after_graphic: bool,
}
/// The fractions Expert Fractions writes as one character: every fraction Unicode encodes as a
/// vulgar fraction with a numerator of 1 to 7 and a denominator of 2 to 10.
const FRACTIONS: [(&str, char); 18] = [
("1/2", '½'),
("1/3", '⅓'),
("2/3", '⅔'),
("1/4", '¼'),
("3/4", '¾'),
("1/5", '⅕'),
("2/5", '⅖'),
("3/5", '⅗'),
("4/5", '⅘'),
("1/6", '⅙'),
("5/6", '⅚'),
("1/7", '⅐'),
("1/8", '⅛'),
("3/8", '⅜'),
("5/8", '⅝'),
("7/8", '⅞'),
("1/9", '⅑'),
("1/10", '⅒'),
];
/// `s` with every `from` replaced by `to`, adding the number replaced to `n`.
fn replace_counted(s: String, from: &str, to: &str, n: &mut usize) -> String {
let found = s.matches(from).count();
if found == 0 {
return s;
}
if ellipsis {
s = s.replace("...", "…");
*n += found;
s.replace(from, to)
}
/// Smart Spaces: `text` without the second and later spaces after a period, adding the number of
/// periods whose spaces it shortened to `n`. `after` carries the spaces after a period from one run
/// to the next.
fn smart_spaces(text: &str, after: &mut Option<usize>, n: &mut usize) -> String {
let mut out = String::with_capacity(text.len());
for c in text.chars() {
match (c, *after) {
(' ', Some(k)) => {
*after = Some(k + 1);
if k >= 1 {
if k == 1 {
*n += 1;
}
continue;
}
}
('.', _) => *after = Some(0),
_ => *after = None,
}
out.push(c);
}
match quotes {
Some(q) => q.apply(&s, prev),
out
}
/// The fraction `cs` starts with, and its length in characters: one of [`FRACTIONS`] that no digit,
/// slash or decimal part follows, so `1/25`, `1/2/2026` and `1/2.5` are left as they are.
fn fraction_at(cs: &[char]) -> Option<(usize, char)> {
FRACTIONS.iter().find_map(|(text, f)| {
let len = text.chars().count();
if cs.len() < len || !cs[..len].iter().copied().eq(text.chars()) {
return None;
}
let ends = match &cs[len..] {
[c, ..] if c.is_ascii_digit() || *c == '/' => false,
['.' | ',', d, ..] if d.is_ascii_digit() => false,
_ => true,
};
ends.then_some((len, *f))
})
}
/// Expert Fractions: `text` with each fraction [`fraction_at`] finds, and no digit, slash or
/// decimal point before, written as one character when `covers` it. `prev` is the character before
/// `text`, and `next` the two characters after it (in the next runs), so a fraction at the end of
/// a run is checked against what follows it.
fn expert_fractions(text: &str, prev: Option<char>, next: [Option<char>; 2], covers: &mut impl FnMut(char) -> bool, n: &mut usize) -> String {
let mut cs: Vec<char> = text.chars().collect();
let len_text = cs.len();
cs.extend(next.into_iter().flatten());
let mut out = String::with_capacity(text.len());
let mut i = 0;
while i < len_text {
let before = if i == 0 { prev } else { Some(cs[i - 1]) };
let free = !before.is_some_and(|c| c.is_ascii_digit() || matches!(c, '/' | '.' | ','));
let found = fraction_at(&cs[i..]).filter(|(len, f)| i + len <= len_text && covers(*f));
if free && let Some((len, f)) = found {
out.push(f);
*n += 1;
i += len;
continue;
}
out.push(cs[i]);
i += 1;
}
out
}
/// The ligatures and their letters, longest first, with whether each comes with the ff, fi, ffi
/// option (else with the ff, fl, ffl option). ff comes with both.
const LIGATURES: [(&str, char, bool); 5] =
[("ffi", '\u{FB03}', true), ("ffl", '\u{FB04}', false), ("ff", '\u{FB00}', true), ("fi", '\u{FB01}', true), ("fl", '\u{FB02}', false)];
/// The ligature options: `text` with the letters of each ligature an option `o` asks for written
/// as the ligature, the longest first, when `covers` it.
fn ligatures(text: &str, o: &Punct, covers: &mut impl FnMut(char) -> bool, n: &mut PunctCounts) -> String {
let cs: Vec<char> = text.chars().collect();
let mut out = String::with_capacity(text.len());
let mut i = 0;
while i < cs.len() {
let found = (cs[i] == 'f').then(|| {
LIGATURES.iter().find(|(letters, lig, fi)| {
let on = if *letters == "ff" {
o.fi_ligatures || o.fl_ligatures
} else if *fi {
o.fi_ligatures
} else {
o.fl_ligatures
};
let len = letters.chars().count();
on && cs.len() - i >= len && cs[i..i + len].iter().copied().eq(letters.chars()) && covers(*lig)
})
});
if let Some(&(letters, lig, fi)) = found.flatten() {
out.push(lig);
// ff counts with the ff, fi, ffi option when that option is on.
if fi && (letters != "ff" || o.fi_ligatures) {
n.fi_ligatures += 1;
} else {
n.fl_ligatures += 1;
}
i += letters.chars().count();
continue;
}
out.push(cs[i]);
i += 1;
}
out
}
/// One run's text with the replacements `o` asks for, counted in `n`. Ligatures and fractions are
/// written only where the run's font has a glyph for them. `next` holds the two characters after
/// the run.
fn smarten(text: &str, style: &CharStyle, next: [Option<char>; 2], o: &Punct, st: &mut PunctState, n: &mut PunctCounts) -> String {
let mut s = if o.spaces { smart_spaces(text, &mut st.after_period, &mut n.spaces) } else { text.to_string() };
if o.dashes {
s = replace_counted(s, "---", "—", &mut n.dashes);
s = replace_counted(s, "--", "–", &mut n.dashes);
}
if o.ellipses {
s = replace_counted(s, "...", "…", &mut n.ellipses);
}
// The run's font, looked up once and only for a ligature or a fraction.
let mut face = None;
let mut covers = |c: char| {
face.get_or_insert_with(|| {
vectorcraft_text::FontDb::global().face_version(&style.font_family, &style.font_style, style.font_version.as_deref())
})
.as_ref()
.is_some_and(|f| f.covers(c))
};
if o.fractions && s.contains('/') {
let before = if st.after_graphic { None } else { st.prev };
s = expert_fractions(&s, before, next, &mut covers, &mut n.fractions);
}
st.after_graphic = false;
if (o.fi_ligatures || o.fl_ligatures) && s.contains('f') {
s = ligatures(&s, o, &mut covers, n);
}
match &o.quotes {
Some(q) => {
let out = q.apply(&s, &mut st.prev);
n.quotes += s.chars().zip(out.chars()).filter(|(a, b)| a != b).count();
out
}
None => {
*prev = s.chars().last().or(*prev);
st.prev = s.chars().last().or(st.prev);
s
}
}
@@ -293,12 +495,20 @@ pub(crate) fn smarten(text: &str, prev: &mut Option<char>, quotes: Option<&Quote
fn smart_punctuation(s: &mut Session, p: &Value) -> Result<Value> {
const C: &str = "type.smartPunctuation";
let (d, e) = (switch_or(p, "dashes", true, C)?, switch_or(p, "ellipsis", true, C)?);
let quotes = switch_or(p, "quotes", true, C)?;
let mut o = Punct {
fi_ligatures: switch_or(p, "fiLigatures", false, C)?,
fl_ligatures: switch_or(p, "flLigatures", false, C)?,
quotes: None,
spaces: switch_or(p, "spaces", false, C)?,
dashes: switch_or(p, "dashes", true, C)?,
ellipses: switch_or(p, "ellipsis", true, C)?,
fractions: switch_or(p, "fractions", false, C)?,
};
let document = choice(p, C, "scope", &["selection", "document"])? == Some("document");
let st = s.doc()?;
// Quotes in the document's style (Document Setup → Type).
let q = quotes.then_some(st.doc.setup.quotes);
o.quotes = quotes.then_some(st.doc.setup.quotes);
let ids = if document || st.selection.is_empty() {
let mut v = vec![];
st.doc.walk(|n| {
@@ -310,8 +520,51 @@ fn smart_punctuation(s: &mut Session, p: &Value) -> Result<Value> {
} else {
text_ids(&st.doc, &st.selection.objects)
};
let n = edit_runs::<PunctState>(s, "Smart Punctuation", &ids, |text, st| smarten(text, &mut st.prev, q.as_ref(), d, e))?;
Ok(json!({ "changed": n }))
let mut n = PunctCounts::default();
let changed = super::overprint::edit_counted(s, "Smart Punctuation", |d| {
let mut changed = 0;
for id in &ids {
let Some(NodeKind::Text(t)) = d.node_mut(*id).map(|n| &mut n.kind) else { continue };
let mut st = PunctState::default();
let mut any = false;
// Inline graphics are art, not characters to rewrite. Each run sees the first two
// characters of the runs after it, up to the next inline graphic, as they were.
for i in 0..t.runs.len() {
if t.runs[i].inline.is_some() {
// A graphic separates the characters on either side of it for Smart Spaces and
// Expert Fractions; quotes still read the character before it.
st.after_period = None;
st.after_graphic = true;
continue;
}
let mut after = t.runs[i + 1..].iter().take_while(|r| r.inline.is_none()).flat_map(|r| r.text.chars());
let next = [after.next(), after.next()];
let r = &mut t.runs[i];
let new = smarten(&r.text, &r.style, next, &o, &mut st, &mut n);
if new != r.text {
r.text = new;
any = true;
}
}
if any {
changed += 1;
refresh_bounds(t);
}
}
Ok(changed)
})?;
Ok(json!({
"changed": changed,
"replaced": {
"fiLigatures": n.fi_ligatures,
"flLigatures": n.fl_ligatures,
"quotes": n.quotes,
"spaces": n.spaces,
"dashes": n.dashes,
"ellipses": n.ellipses,
"fractions": n.fractions,
},
}))
}
// ---------- Area / Point conversion ----------
+111 -1
View File
@@ -2226,6 +2226,10 @@ fn type_menu_and_find_commands_refuse_a_param_of_the_wrong_type() {
("type.smartPunctuation", json!({"dashes": "false"}), switch("dashes")),
("type.smartPunctuation", json!({"ellipsis": 0}), switch("ellipsis")),
("type.smartPunctuation", json!({"quotes": "no"}), switch("quotes")),
("type.smartPunctuation", json!({"fiLigatures": 1}), switch("fiLigatures")),
("type.smartPunctuation", json!({"flLigatures": "true"}), switch("flLigatures")),
("type.smartPunctuation", json!({"spaces": "on"}), switch("spaces")),
("type.smartPunctuation", json!({"fractions": [true]}), switch("fractions")),
("type.smartPunctuation", json!({"scope": 5}), scope.clone()),
("type.smartPunctuation", json!({"scope": "page"}), scope),
("type.changeCase", json!({"case": 5}), string("case")),
@@ -3555,12 +3559,118 @@ fn smart_punctuation_with_nothing_to_change_records_no_undo_step() {
for id in [t, r] {
select_with_a_step_to_redo(&mut s, &[id]);
let before = history(&s);
assert_eq!(s.execute("type.smartPunctuation", &json!({})).unwrap(), json!({"changed": 0}), "{id:?}");
let r = s.execute("type.smartPunctuation", &json!({})).unwrap();
assert_eq!(r["changed"], 0, "{id:?}");
assert!(r["replaced"].as_object().unwrap().values().all(|n| n == 0), "{id:?}: {r}");
assert_eq!(history(&s), before, "{id:?}");
}
assert_eq!(plain(&s, t), "“Hi” it’s 1–2 and 3—4…");
}
/// Does the face text `font` draws with have a glyph for every character of `chars`?
fn font_covers(font: &str, chars: &str) -> bool {
let face = vectorcraft_text::FontDb::global().face(font, "Regular");
face.is_some_and(|f| chars.chars().all(|c| f.covers(c)))
}
/// Every option on: the ligatures, Smart Spaces and Expert Fractions, each counted on its own, in
/// one undo step. Fractions next to a digit, a slash or a decimal part are left as they are.
#[test]
fn smart_punctuation_ligatures_spaces_and_fractions_are_counted() {
let mut s = session();
assert!(font_covers("Source Sans 3", "\u{FB00}\u{FB01}\u{FB02}\u{FB03}\u{FB04}½¾"), "Source Sans 3 draws the ligatures and fractions");
let words = "An office's fluffy flow. Then 1/2 and 3/4, not 1/25, 1/2/26 or 1/2.5.";
let t = id_of(&s.execute("text.create", &json!({"x": 50, "y": 50, "text": words, "font": "Source Sans 3"})).unwrap());
sel(&mut s, &[t]);
let undo = history(&s).0;
let all = json!({"fiLigatures": true, "flLigatures": true, "quotes": true, "spaces": true, "dashes": true, "ellipsis": true, "fractions": true});
let r = s.execute("type.smartPunctuation", &all).unwrap();
assert_eq!(plain(&s, t), "An o\u{FB03}ce’s \u{FB02}u\u{FB00}y \u{FB02}ow. Then ½ and ¾, not 1/25, 1/2/26 or 1/2.5.");
let replaced = json!({"fiLigatures": 2, "flLigatures": 2, "quotes": 1, "spaces": 1, "dashes": 0, "ellipses": 0, "fractions": 2});
assert_eq!(r, json!({"changed": 1, "replaced": replaced}));
assert_eq!(history(&s).0, undo + 1);
}
/// The ff, fl, ffl option alone leaves fi and ffi as letters (ffi keeps its ff ligature, counted
/// with this option), and the other options are off unless asked for.
#[test]
fn smart_punctuation_fl_ligatures_alone() {
let mut s = session();
let t = id_of(&s.execute("text.create", &json!({"x": 50, "y": 50, "text": "office fit baffle. 1/2", "font": "Source Sans 3"})).unwrap());
sel(&mut s, &[t]);
let r = s.execute("type.smartPunctuation", &json!({"flLigatures": true})).unwrap();
assert_eq!(plain(&s, t), "o\u{FB00}ice fit ba\u{FB04}e. 1/2");
assert_eq!(r["replaced"], json!({"fiLigatures": 0, "flLigatures": 2, "quotes": 0, "spaces": 0, "dashes": 0, "ellipses": 0, "fractions": 0}));
}
/// A ligature or a fraction the run's font has no glyph for stays as its letters, while the run's
/// other replacements still happen.
#[test]
fn smart_punctuation_skips_ligatures_and_fractions_the_font_lacks() {
let mut s = session();
let mono = "JetBrains Mono";
assert!(!font_covers(mono, "\u{FB01}") && !font_covers(mono, "⅐"), "{mono} has no fi ligature or one-seventh");
let t = id_of(&s.execute("text.create", &json!({"x": 50, "y": 50, "text": "fit 1/7 a--b", "font": mono})).unwrap());
sel(&mut s, &[t]);
let r = s.execute("type.smartPunctuation", &json!({"fiLigatures": true, "fractions": true})).unwrap();
assert_eq!(plain(&s, t), "fit 1/7 a–b");
let counts = (&r["replaced"]["fiLigatures"], &r["replaced"]["fractions"], &r["replaced"]["dashes"]);
assert_eq!(counts, (&json!(0), &json!(0), &json!(1)));
}
/// A fraction at the end of a run is checked against the start of the next run: 1/25 and 1/2.5
/// split after their 1/2 stay as they are, and a 1/2 the next run's space ends is replaced.
#[test]
fn expert_fractions_look_past_the_end_of_a_run() {
let mut s = session();
let t = id_of(&s.execute("text.create", &json!({"x": 50, "y": 50, "text": "1/25 1/2.5 1/2 x", "font": "Source Sans 3"})).unwrap());
for (start, end) in [(0, 3), (5, 8), (11, 14)] {
s.execute("text.setRangeStyle", &json!({"id": t.0, "start": start, "end": end, "size": 30})).unwrap();
}
sel(&mut s, &[t]);
let r = s.execute("type.smartPunctuation", &json!({"fractions": true})).unwrap();
assert_eq!(plain(&s, t), "1/25 1/2.5 ½ x");
assert_eq!(r["replaced"]["fractions"], 1);
}
/// An inline graphic separates the text on either side of it: the space after it is not a second
/// space after the period before it, and the digit before it does not stop a fraction after it.
#[test]
fn an_inline_graphic_separates_smart_spaces_and_fractions() {
let mut s = session();
let r = rect(&mut s, 600.0, 500.0, 10.0, 10.0);
sel(&mut s, &[r]);
s.execute("symbol.new", &json!({"name": "Mark"})).unwrap();
s.execute("edit.clear", &json!({})).unwrap();
let t = id_of(&s.execute("text.create", &json!({"x": 50, "y": 50, "text": "A. B 71/2", "font": "Source Sans 3"})).unwrap());
s.execute("text.insertInline", &json!({"id": t.0, "at": 7, "symbol": "Mark"})).unwrap();
s.execute("text.insertInline", &json!({"id": t.0, "at": 3, "symbol": "Mark"})).unwrap();
let texts = |s: &Session| match node(s, t).kind {
NodeKind::Text(o) => o.runs.iter().map(|r| if r.inline.is_some() { "[g]".to_string() } else { r.text.clone() }).collect::<String>(),
_ => String::new(),
};
assert_eq!(texts(&s), "A. [g] B 7[g]1/2");
sel(&mut s, &[t]);
let r = s.execute("type.smartPunctuation", &json!({"spaces": true, "fractions": true})).unwrap();
assert_eq!(texts(&s), "A. [g] B 7[g]½");
assert_eq!((&r["replaced"]["spaces"], &r["replaced"]["fractions"]), (&json!(0), &json!(1)));
}
/// Smart Spaces keeps one space after each period, also when the spaces start in the next run,
/// and leaves single spaces and spaces after other characters alone.
#[test]
fn smart_spaces_keeps_one_space_after_a_period() {
let mut s = session();
let t = text(&mut s, "A. B. C. D E");
// "C." is in a run of its own, and the spaces after it start the next one.
s.execute("text.setRangeStyle", &json!({"id": t.0, "start": 8, "end": 10, "size": 30})).unwrap();
assert!(matches!(node(&s, t).kind, NodeKind::Text(ref o) if o.runs.len() > 1));
sel(&mut s, &[t]);
let r = s.execute("type.smartPunctuation", &json!({"spaces": true, "quotes": false, "dashes": false, "ellipsis": false})).unwrap();
assert_eq!(plain(&s, t), "A. B. C. D E");
assert_eq!(r["replaced"]["spaces"], 2);
}
#[test]
fn convert_point_area_roundtrip() {
let mut s = session();
+2
View File
@@ -122,6 +122,7 @@ pub(crate) mod shapes;
pub mod shortcut_import;
pub(crate) mod simplify_slider;
pub mod slices;
pub mod smart_punctuation;
pub(crate) mod smooth_slider;
pub mod spot_colors;
pub mod svg_filter;
@@ -430,6 +431,7 @@ registry! {
VectorHalftone: [halftone::KIND] => halftone::SPEC,
SimplifySlider: [simplify_slider::KIND] => simplify_slider::SPEC,
SmoothSlider: [smooth_slider::KIND] => smooth_slider::SPEC,
SmartPunctuation: [smart_punctuation::KIND] => smart_punctuation::SPEC,
PerspectiveGrid: [perspective_grid::KIND] => perspective_grid::SPEC,
Envelope: [envelope::WARP, envelope::MESH, envelope::OPTIONS] => envelope::SPEC,
LiquifyOptions: [liquify::KIND] => liquify::SPEC,
@@ -0,0 +1,169 @@
//! Type › Smart Punctuation…: which keyboard characters to replace with their typographic forms,
//! where (the selected type or the whole document) and whether to report how many of each were
//! replaced. OK runs `type.smartPunctuation` as one undo step, and the dialog opens on the fields
//! confirmed last.
//!
//! Fields: the switches `fiLigatures`, `flLigatures`, `quotes`, `spaces`, `dashes`, `ellipsis` and
//! `fractions`, `scope` (`selection` or `document`) and `report`.
use serde_json::{Value, json};
use super::{DialogResult, DialogSpec, form, run_and_close};
use crate::state::Dialog;
use crate::{VectorcraftApp, widgets};
/// The dialog kind of Smart Punctuation.
pub const KIND: &str = "smartPunctuation";
const CMD: &str = "type.smartPunctuation";
pub(super) const SPEC: DialogSpec = DialogSpec { heading: |_| tl!("Smart Punctuation").into(), body, confirm, min_width: 300.0, ..DialogSpec::FORM };
/// The replacement options in the dialog's order: (field, the key of their count in the
/// command's reply, label).
fn options() -> [(&'static str, &'static str, &'static str); 7] {
[
("fiLigatures", "fiLigatures", tl!("ff, fi, ffi Ligatures")),
("flLigatures", "flLigatures", tl!("ff, fl, ffl Ligatures")),
("quotes", "quotes", tl!("Smart Quotes")),
("spaces", "spaces", tl!("Smart Spaces")),
("dashes", "dashes", tl!("En, Em Dashes")),
("ellipsis", "ellipses", tl!("Ellipses")),
("fractions", "fractions", tl!("Expert Fractions")),
]
}
/// The fields the menu item opens with: those confirmed last, else quotes, dashes and ellipses on
/// (the command's defaults). With nothing selected, the whole document.
pub fn fields(app: &VectorcraftApp) -> Value {
let mut f = match &app.ui.smart_punctuation {
Value::Object(o) => Value::Object(o.clone()),
_ => json!({
"fiLigatures": false,
"flLigatures": false,
"quotes": true,
"spaces": false,
"dashes": true,
"ellipsis": true,
"fractions": false,
"scope": "selection",
"report": false,
}),
};
if !has_selection(app) {
f["scope"] = json!("document");
}
f
}
fn has_selection(app: &VectorcraftApp) -> bool {
app.session.active().is_some_and(|d| !d.selection.is_empty())
}
/// The command's parameters: the switches and the scope.
fn params(d: &Dialog) -> Value {
let mut p = serde_json::Map::new();
for (key, ..) in options() {
p.insert(key.into(), json!(d.bool(key)));
}
p.insert("scope".into(), json!(if d.str("scope") == "document" { "document" } else { "selection" }));
Value::Object(p)
}
fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
for (key, _, label) in options() {
form::check(ui, d, key, label);
}
ui.add_space(8.0);
widgets::section_header(ui, tl!("Replace In"));
let selected = has_selection(app);
let scope = d.str("scope");
for (value, label, enabled) in [("selection", tl!("Selected Text Only"), selected), ("document", tl!("Entire Document"), true)] {
let on = if selected { scope == value } else { value == "document" };
if widgets::radio(ui, label, on, enabled) {
d.fields.insert("scope".into(), json!(value));
}
}
ui.add_space(8.0);
form::check(ui, d, "report", tl!("Report Results"));
false
}
/// Runs the command, keeps the fields for the next time, and with Report Results on lists how many
/// of each chosen replacement it made.
fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> DialogResult {
let r = run_and_close(app, CMD, params(d))?;
app.ui.smart_punctuation = Value::Object(d.fields.clone());
if d.bool("report") {
let lines: Vec<String> = options()
.into_iter()
.filter(|(key, ..)| d.bool(key))
.map(|(_, count, label)| format!("{label}: {}", r["replaced"][count].as_u64().unwrap_or(0)))
.collect();
super::confirm::tell(app, tl!("Smart Punctuation"), &lines.join("\n"));
}
Ok(r)
}
#[cfg(test)]
mod tests {
use super::*;
use vectorcraft_engine::Session;
fn app_with_text(text: &str) -> (VectorcraftApp, u64) {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 200, "height": 100})).unwrap();
let id = app.run("text.create", json!({"x": 10, "y": 40, "text": text, "font": "Source Sans 3"})).unwrap()["id"].as_u64().unwrap();
(app, id)
}
fn plain(app: &VectorcraftApp, id: u64) -> String {
match &app.session.doc().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().kind {
vectorcraft_doc::NodeKind::Text(t) => t.plain_text(),
_ => String::new(),
}
}
/// The menu item opens the dialog; OK replaces in one undo step, reports each chosen
/// replacement's count, and the next opening starts from the fields confirmed.
#[test]
fn menu_item_opens_the_dialog_and_ok_reports_the_counts() {
let (mut app, id) = app_with_text("\"Hi\". 1/2 -- off");
app.run("select.set", json!({"ids": [id]})).unwrap();
crate::menus::invoke(&mut app, CMD, json!({}));
let d = app.ui.dialog.as_mut().expect("Smart Punctuation opens");
assert_eq!((d.kind.as_str(), d.str("scope")), (KIND, "selection".to_string()));
for key in ["spaces", "fractions", "fiLigatures", "report"] {
d.fields.insert(key.into(), json!(true));
}
d.fields.insert("ellipsis".into(), json!(false));
let undo = app.session.doc().unwrap().history.undo.len();
super::super::confirm(&mut app).unwrap();
assert_eq!(plain(&app, id), "“Hi”. ½ – o\u{FB00}");
assert_eq!(app.session.doc().unwrap().history.undo.len(), undo + 1);
let told = app.ui.dialog.as_ref().expect("Report Results shows the counts");
assert_eq!(told.kind, crate::dialogs::confirm::MESSAGE);
assert_eq!(told.str("detail"), "ff, fi, ffi Ligatures: 1\nSmart Quotes: 2\nSmart Spaces: 1\nEn, Em Dashes: 1\nExpert Fractions: 1");
app.ui.dialog = None;
crate::menus::invoke(&mut app, CMD, json!({}));
let again = app.ui.dialog.as_ref().unwrap();
assert!(again.bool("fractions") && again.bool("report") && !again.bool("ellipsis"));
}
/// With nothing selected the dialog replaces in the entire document, and without Report
/// Results it shows no message. An unchanged document keeps its undo history.
#[test]
fn with_nothing_selected_the_whole_document_is_replaced() {
let (mut app, id) = app_with_text("a--b");
app.run("select.none", json!({})).unwrap();
crate::menus::invoke(&mut app, CMD, json!({}));
assert_eq!(app.ui.dialog.as_ref().unwrap().str("scope"), "document");
super::super::confirm(&mut app).unwrap();
assert_eq!(plain(&app, id), "a–b");
assert!(app.ui.dialog.is_none());
let undo = app.session.doc().unwrap().history.undo.len();
crate::menus::invoke(&mut app, CMD, json!({}));
super::super::confirm(&mut app).unwrap();
assert_eq!(app.session.doc().unwrap().history.undo.len(), undo);
}
}
+12
View File
@@ -3348,6 +3348,18 @@ digits Malayalam Малаялам
Smart Guides (View → Smart Guides) Интелигентни водачи (Изглед → Интелигентни водачи)
Smart Guides (⌘U) Интелигентни водачи (⌘U)
Smart Punctuation… Интелигентна пунктуация…
Smart Punctuation Интелигентна пунктуация
ff, fi, ffi Ligatures Лигатури ff, fi, ffi
ff, fl, ffl Ligatures Лигатури ff, fl, ffl
Smart Quotes Интелигентни кавички
Smart Spaces Интелигентни интервали
En, Em Dashes Средни и дълги тирета
Ellipses Многоточия
Expert Fractions Експертни дроби
Replace In Замяна в
Selected Text Only Само избрания текст
Entire Document Целия документ
Report Results Отчет за резултатите
Smooth Гладък
Corner Ъгъл
Relative Относителен
Can't render this file because it contains an unexpected character in line 2 and column 73.
+12
View File
@@ -421,6 +421,18 @@
Title Case Svaka Riječ Velikim Slovom
Sentence case Veliko početno slovo rečenice
Smart Punctuation… Pametna interpunkcija…
Smart Punctuation Pametna interpunkcija
ff, fi, ffi Ligatures Ligature ff, fi, ffi
ff, fl, ffl Ligatures Ligature ff, fl, ffl
Smart Quotes Pametni navodnici
Smart Spaces Pametni razmaci
En, Em Dashes Srednje i duge crtice
Ellipses Tri tačke
Expert Fractions Stručni razlomci
Replace In Zamijeni u
Selected Text Only Samo odabrani tekst
Entire Document Cijeli dokument
Report Results Izvještaj o rezultatima
Create Outlines Kreiraj obrise
Optical Margin Alignment Optičko poravnanje margina
Dynamic Text Dinamički tekst
Can't render this file because it contains an unexpected character in line 2 and column 73.
+12
View File
@@ -4372,6 +4372,18 @@ digits Malayalam Malaiàlam
Smart Guides (View → Smart Guides) Guies intel·ligents (Visualitza → Guies intel·ligents)
Smart Guides (⌘U) Guies intel·ligents (⌘U)
Smart Punctuation… Puntuació intel·ligent…
Smart Punctuation Puntuació intel·ligent
ff, fi, ffi Ligatures Lligadures ff, fi, ffi
ff, fl, ffl Ligatures Lligadures ff, fl, ffl
Smart Quotes Cometes intel·ligents
Smart Spaces Espais intel·ligents
En, Em Dashes Ratlles en i em
Ellipses Punts suspensius
Expert Fractions Fraccions expertes
Replace In Reemplaça a
Selected Text Only Només el text seleccionat
Entire Document Tot el document
Report Results Informa dels resultats
Smooth Suavitza
Smooth Color Color suau
Smooth Tool Eina de suavitzat
Can't render this file because it contains an unexpected character in line 2 and column 73.
+12
View File
@@ -428,6 +428,18 @@
Title Case Velká Počáteční Písmena
Sentence case Velké první písmeno věty
Smart Punctuation… Inteligentní interpunkce…
Smart Punctuation Inteligentní interpunkce
ff, fi, ffi Ligatures Ligatury ff, fi, ffi
ff, fl, ffl Ligatures Ligatury ff, fl, ffl
Smart Quotes Inteligentní uvozovky
Smart Spaces Inteligentní mezery
En, Em Dashes Krátké a dlouhé pomlčky
Ellipses Výpustky
Expert Fractions Odborné zlomky
Replace In Nahradit v
Selected Text Only Pouze vybraný text
Entire Document Celý dokument
Report Results Zobrazit výsledky
Create Outlines Převést na křivky
Optical Margin Alignment Optické zarovnání okrajů
Dynamic Text Dynamický text
Can't render this file because it is too large.
+12
View File
@@ -389,6 +389,18 @@
Title Case Stort bogstav i hvert ord
Sentence case Stort begyndelsesbogstav
Smart Punctuation… Smart tegnsætning…
Smart Punctuation Smart tegnsætning
ff, fi, ffi Ligatures Ligaturer ff, fi, ffi
ff, fl, ffl Ligatures Ligaturer ff, fl, ffl
Smart Quotes Smarte anførselstegn
Smart Spaces Smarte mellemrum
En, Em Dashes Korte og lange tankestreger
Ellipses Udeladelsesprikker
Expert Fractions Ekspertbrøker
Replace In Erstat i
Selected Text Only Kun markeret tekst
Entire Document Hele dokumentet
Report Results Rapportér resultater
Create Outlines Opret konturer
Optical Margin Alignment Optisk marginjustering
Dynamic Text Dynamisk tekst
Can't render this file because it contains an unexpected character in line 2 and column 73.
+12
View File
@@ -3411,6 +3411,18 @@ effect Points Punkte
Smart Guides (View → Smart Guides) Intelligente Hilfslinien (Ansicht → Intelligente Hilfslinien)
Smart Guides (⌘U) Intelligente Hilfslinien (⌘U)
Smart Punctuation… Typografische Satzzeichen…
Smart Punctuation Typografische Satzzeichen
ff, fi, ffi Ligatures Ligaturen ff, fi, ffi
ff, fl, ffl Ligatures Ligaturen ff, fl, ffl
Smart Quotes Typografische Anführungszeichen
Smart Spaces Intelligente Leerzeichen
En, Em Dashes Halbgeviert- und Geviertstriche
Ellipses Auslassungspunkte
Expert Fractions Expertenbrüche
Replace In Ersetzen in
Selected Text Only Nur ausgewählter Text
Entire Document Gesamtes Dokument
Report Results Ergebnisse anzeigen
Smooth Glatt
Corner Ecke
Relative Relativ
Can't render this file because it is too large.
+12
View File
@@ -3981,6 +3981,18 @@ digits Malayalam Μαλαγιάλαμ
Smart Guides (View → Smart Guides) Έξυπνοι οδηγοί (Προβολή → Έξυπνοι οδηγοί)
Smart Guides (⌘U) Έξυπνοι οδηγοί (⌘U)
Smart Punctuation… Έξυπνη στίξη…
Smart Punctuation Έξυπνη στίξη
ff, fi, ffi Ligatures Συμπλέγματα ff, fi, ffi
ff, fl, ffl Ligatures Συμπλέγματα ff, fl, ffl
Smart Quotes Έξυπνα εισαγωγικά
Smart Spaces Έξυπνα διαστήματα
En, Em Dashes Παύλες en και em
Ellipses Αποσιωπητικά
Expert Fractions Κλάσματα ειδικών
Replace In Αντικατάσταση σε
Selected Text Only Μόνο επιλεγμένο κείμενο
Entire Document Ολόκληρο το έγγραφο
Report Results Αναφορά αποτελεσμάτων
Smooth Color Ομαλό χρώμα
Smooth Tool Εξομάλυνση (Smooth Tool)
Snap Curves To Lines Προσκόλληση καμπυλών σε γραμμές
Can't render this file because it is too large.
+12
View File
@@ -3441,6 +3441,18 @@ digits Malayalam Malayálam
Smart Guides (View → Smart Guides) Guías inteligentes (Ver → Guías inteligentes)
Smart Guides (⌘U) Guías inteligentes (⌘U)
Smart Punctuation… Puntuación inteligente…
Smart Punctuation Puntuación inteligente
ff, fi, ffi Ligatures Ligaduras ff, fi, ffi
ff, fl, ffl Ligatures Ligaduras ff, fl, ffl
Smart Quotes Comillas inteligentes
Smart Spaces Espacios inteligentes
En, Em Dashes Semirrayas y rayas
Ellipses Puntos suspensivos
Expert Fractions Fracciones expertas
Replace In Reemplazar en
Selected Text Only Solo el texto seleccionado
Entire Document Todo el documento
Report Results Informar de los resultados
Smooth Suavizar
Corner Vértice
Relative Relativo
Can't render this file because it contains an unexpected character in line 2 and column 73.
+12
View File
@@ -425,6 +425,18 @@
Title Case Otsikon kirjainkoko
Sentence case Virkkeen kirjainkoko
Smart Punctuation… Älykäs välimerkitys…
Smart Punctuation Älykäs välimerkitys
ff, fi, ffi Ligatures Ligatuurit ff, fi, ffi
ff, fl, ffl Ligatures Ligatuurit ff, fl, ffl
Smart Quotes Älykkäät lainausmerkit
Smart Spaces Älykkäät välilyönnit
En, Em Dashes Lyhyet ja pitkät ajatusviivat
Ellipses Kolme pistettä
Expert Fractions Erikoismurtoluvut
Replace In Korvaa kohteessa
Selected Text Only Vain valittu teksti
Entire Document Koko asiakirja
Report Results Näytä tulokset
Create Outlines Muunna ääriviivoiksi
Optical Margin Alignment Optinen reunustasaus
Dynamic Text Dynaaminen teksti
Can't render this file because it contains an unexpected character in line 2 and column 73.
+12
View File
@@ -3433,6 +3433,18 @@ digits Malayalam Malayalam
Smart Guides (View → Smart Guides) Repères commentés (Affichage → Repères commentés)
Smart Guides (⌘U) Repères commentés (⌘U)
Smart Punctuation… Ponctuation typographique…
Smart Punctuation Ponctuation typographique
ff, fi, ffi Ligatures Ligatures ff, fi, ffi
ff, fl, ffl Ligatures Ligatures ff, fl, ffl
Smart Quotes Guillemets typographiques
Smart Spaces Espaces typographiques
En, Em Dashes Tirets demi-cadratin et cadratin
Ellipses Points de suspension
Expert Fractions Fractions expertes
Replace In Remplacer dans
Selected Text Only Texte sélectionné uniquement
Entire Document Document entier
Report Results Afficher les résultats
Smooth Lisser
Corner Angle
Relative Relatif
Can't render this file because it is too large.
+12
View File
@@ -3561,6 +3561,18 @@
Smart Pen Panel સ્માર્ટ પેન પેનલ
Smart Pen Tool સ્માર્ટ પેન ટૂલ
Smart Punctuation… સ્માર્ટ વિરામચિહ્નો…
Smart Punctuation સ્માર્ટ વિરામચિહ્નો
ff, fi, ffi Ligatures ff, fi, ffi લિગેચર
ff, fl, ffl Ligatures ff, fl, ffl લિગેચર
Smart Quotes સ્માર્ટ અવતરણચિહ્નો
Smart Spaces સ્માર્ટ જગ્યાઓ
En, Em Dashes En અને Em ડૅશ
Ellipses એલિપ્સિસ
Expert Fractions નિષ્ણાત અપૂર્ણાંકો
Replace In આમાં બદલો
Selected Text Only માત્ર પસંદ કરેલું લખાણ
Entire Document આખો દસ્તાવેજ
Report Results પરિણામોનો અહેવાલ
Smooth સ્મૂધ
Smooth Anchors… એન્કર સ્મૂધ કરો…
Smooth Tool સ્મૂધ ટૂલ
Can't render this file because it contains an unexpected character in line 72 and column 5.
+12
View File
@@ -4726,6 +4726,18 @@ antiAlias Sharp शार्प
Smart Pen Panel स्मार्ट पेन पैनल
Smart Pen Tool स्मार्ट पेन टूल
Smart Punctuation… स्मार्ट विराम-चिह्न…
Smart Punctuation स्मार्ट विराम-चिह्न
ff, fi, ffi Ligatures ff, fi, ffi लिगेचर
ff, fl, ffl Ligatures ff, fl, ffl लिगेचर
Smart Quotes स्मार्ट उद्धरण-चिह्न
Smart Spaces स्मार्ट स्पेस
En, Em Dashes एन और एम डैश
Ellipses दीर्घविराम
Expert Fractions विशेषज्ञ भिन्न
Replace In इसमें रिप्लेस करें
Selected Text Only केवल सिलेक्ट किया गया टेक्स्ट
Entire Document पूरा डॉक्यूमेंट
Report Results परिणाम रिपोर्ट करें
Smooth स्मूथ
Smooth Anchors चिकना एंकर
Smooth Anchors… चिकना एंकर…
Can't render this file because it is too large.
+12
View File
@@ -4093,6 +4093,18 @@ mark-style Japanese Japán
Smart Guides (View → Smart Guides) Intelligens segédvonalak (Nézet → Intelligens segédvonalak)
Smart Guides (⌘U) Intelligens segédvonalak (⌘U)
Smart Punctuation… Intelligens írásjelek…
Smart Punctuation Intelligens írásjelek
ff, fi, ffi Ligatures ff, fi, ffi ligatúrák
ff, fl, ffl Ligatures ff, fl, ffl ligatúrák
Smart Quotes Intelligens idézőjelek
Smart Spaces Intelligens szóközök
En, Em Dashes Gondolatjelek és nagykötőjelek
Ellipses Három pont
Expert Fractions Szakértői törtek
Replace In Csere helye
Selected Text Only Csak a kijelölt szöveg
Entire Document Teljes dokumentum
Report Results Eredmények jelentése
Smooth Simítás
Smooth Color Sima színátmenet
Smooth Tool Simítás
Can't render this file because it is too large.
+12
View File
@@ -389,6 +389,18 @@
Title Case Huruf besar di awal kata
Sentence case Huruf besar di awal kalimat
Smart Punctuation… Tanda baca cerdas…
Smart Punctuation Tanda baca cerdas
ff, fi, ffi Ligatures Ligatur ff, fi, ffi
ff, fl, ffl Ligatures Ligatur ff, fl, ffl
Smart Quotes Tanda kutip cerdas
Smart Spaces Spasi cerdas
En, Em Dashes Tanda pisah en dan em
Ellipses Elipsis
Expert Fractions Pecahan ahli
Replace In Ganti di
Selected Text Only Hanya teks terpilih
Entire Document Seluruh dokumen
Report Results Laporkan hasil
Create Outlines Buat garis luar
Optical Margin Alignment Perataan margin optik
Dynamic Text Teks dinamis
1 # Indonesian (id) catalog. Same format as zh-hant.tsv: context <TAB> source <TAB> translation
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
+12
View File
@@ -3486,6 +3486,18 @@ digits Malayalam Malayalam
Smart Guides (View → Smart Guides) Guide sensibili (Visualizza → Guide sensibili)
Smart Guides (⌘U) Guide sensibili (⌘U)
Smart Punctuation… Punteggiatura intelligente…
Smart Punctuation Punteggiatura intelligente
ff, fi, ffi Ligatures Legature ff, fi, ffi
ff, fl, ffl Ligatures Legature ff, fl, ffl
Smart Quotes Virgolette intelligenti
Smart Spaces Spazi intelligenti
En, Em Dashes Trattini medi e lineette
Ellipses Puntini di sospensione
Expert Fractions Frazioni esperte
Replace In Sostituisci in
Selected Text Only Solo testo selezionato
Entire Document Intero documento
Report Results Mostra risultati
Smooth Smussa
Corner Angolo
Relative Relativo
Can't render this file because it is too large.
+12
View File
@@ -463,6 +463,18 @@ digits Malayalam マラヤーラム数字
Title Case 単語の先頭のみ大文字
Sentence case 文頭のみ大文字
Smart Punctuation… 欧文用字形の自動置換…
Smart Punctuation 欧文用字形の自動置換
ff, fi, ffi Ligatures ff、fi、ffi 合字
ff, fl, ffl Ligatures ff、fl、ffl 合字
Smart Quotes スマート引用符
Smart Spaces スマートスペース
En, Em Dashes EN ダッシュと EM ダッシュ
Ellipses 省略記号
Expert Fractions エキスパート分数
Replace In 置換範囲
Selected Text Only 選択したテキストのみ
Entire Document ドキュメント全体
Report Results 結果を表示
Create Outlines アウトラインを作成
Optical Margin Alignment 最適なマージン揃え
Dynamic Text ダイナミックテキスト
Can't render this file because it is too large.
+12
View File
@@ -354,6 +354,18 @@
Title Case სათაურის რეგისტრი
Sentence case წინადადების რეგისტრი
Smart Punctuation… ჭკვიანი პუნქტუაცია…
Smart Punctuation ჭკვიანი პუნქტუაცია
ff, fi, ffi Ligatures ლიგატურები ff, fi, ffi
ff, fl, ffl Ligatures ლიგატურები ff, fl, ffl
Smart Quotes ჭკვიანი ბრჭყალები
Smart Spaces ჭკვიანი ჰარები
En, Em Dashes მოკლე და გრძელი ტირეები
Ellipses მრავალწერტილები
Expert Fractions ექსპერტული წილადები
Replace In ჩანაცვლების არე
Selected Text Only მხოლოდ მონიშნული ტექსტი
Entire Document მთელი დოკუმენტი
Report Results შედეგების ანგარიში
Create Outlines კონტურებად გარდაქმნა
Optical Margin Alignment ოპტიკური არშიის სწორება
Dynamic Text დინამიკური ტექსტი
Can't render this file because it is too large.
+12
View File
@@ -456,6 +456,18 @@ digits Malayalam 말라얄람어
Title Case 제목 대소문자
Sentence case 문장 대소문자
Smart Punctuation… 스마트 문장 부호…
Smart Punctuation 스마트 문장 부호
ff, fi, ffi Ligatures ff, fi, ffi 합자
ff, fl, ffl Ligatures ff, fl, ffl 합자
Smart Quotes 스마트 따옴표
Smart Spaces 스마트 공백
En, Em Dashes 엔 대시 및 엠 대시
Ellipses 줄임표
Expert Fractions 전문가 분수
Replace In 바꿀 범위
Selected Text Only 선택한 텍스트만
Entire Document 전체 문서
Report Results 결과 보고
Create Outlines 윤곽선 만들기
Optical Margin Alignment 시각적 여백 정렬
Dynamic Text 동적 텍스트
Can't render this file because it is too large.
+12
View File
@@ -907,6 +907,18 @@
Title Case Koptitel
Sentence case Zinsvorm
Smart Punctuation… Slimme interpunctie…
Smart Punctuation Slimme interpunctie
ff, fi, ffi Ligatures Ligaturen ff, fi, ffi
ff, fl, ffl Ligatures Ligaturen ff, fl, ffl
Smart Quotes Slimme aanhalingstekens
Smart Spaces Slimme spaties
En, Em Dashes Halve en hele gedachtestreepjes
Ellipses Beletseltekens
Expert Fractions Expertbreuken
Replace In Vervangen in
Selected Text Only Alleen geselecteerde tekst
Entire Document Hele document
Report Results Resultaten rapporteren
Create Outlines Omzetten in curven
Optical Margin Alignment Optische marge-uitlijning
Dynamic Text Dynamische tekst
Can't render this file because it is too large.
+12
View File
@@ -387,6 +387,18 @@
Title Case Jak W Tytule
Sentence case Jak w zdaniu
Smart Punctuation… Inteligentna interpunkcja…
Smart Punctuation Inteligentna interpunkcja
ff, fi, ffi Ligatures Ligatury ff, fi, ffi
ff, fl, ffl Ligatures Ligatury ff, fl, ffl
Smart Quotes Inteligentne cudzysłowy
Smart Spaces Inteligentne spacje
En, Em Dashes Półpauzy i pauzy
Ellipses Wielokropki
Expert Fractions Ułamki eksperckie
Replace In Zastąp w
Selected Text Only Tylko zaznaczony tekst
Entire Document Cały dokument
Report Results Raportuj wyniki
Create Outlines Utwórz kontury
Optical Margin Alignment Optyczne wyrównanie marginesów
Dynamic Text Tekst dynamiczny
Can't render this file because it is too large.
+12
View File
@@ -2909,6 +2909,18 @@ digits Malayalam Malaiala
Smart Guides (View → Smart Guides) Guias Inteligentes (Exibir → Guias Inteligentes)
Smart Guides (⌘U) Guias Inteligentes (⌘U)
Smart Punctuation… Pontuação Inteligente…
Smart Punctuation Pontuação Inteligente
ff, fi, ffi Ligatures Ligações ff, fi, ffi
ff, fl, ffl Ligatures Ligações ff, fl, ffl
Smart Quotes Aspas Inteligentes
Smart Spaces Espaços Inteligentes
En, Em Dashes Travessões En e Em
Ellipses Reticências
Expert Fractions Frações Especiais
Replace In Substituir Em
Selected Text Only Somente Texto Selecionado
Entire Document Documento Inteiro
Report Results Relatar Resultados
Smooth Suavizar
Smooth Tool Ferramenta Suavizar
Snap Curves To Lines Ajustar Curvas às Linhas
Can't render this file because it is too large.
+12
View File
@@ -3473,6 +3473,18 @@ digits Malayalam Малаялам
Smart Guides (View → Smart Guides) Умные направляющие (Просмотр → Умные направляющие)
Smart Guides (⌘U) Умные направляющие (⌘U)
Smart Punctuation… Умная пунктуация…
Smart Punctuation Умная пунктуация
ff, fi, ffi Ligatures Лигатуры ff, fi, ffi
ff, fl, ffl Ligatures Лигатуры ff, fl, ffl
Smart Quotes Умные кавычки
Smart Spaces Умные пробелы
En, Em Dashes Средние и длинные тире
Ellipses Многоточия
Expert Fractions Экспертные дроби
Replace In Заменить в
Selected Text Only Только выделенный текст
Entire Document Весь документ
Report Results Отчёт о результатах
Smooth Сгладить
Corner Угол
Relative Относительно
Can't render this file because it is too large.
+12
View File
@@ -3363,6 +3363,18 @@ digits Malayalam Malayalam
Smart Guides (View → Smart Guides) Smarta stödlinjer (Visa → Smarta stödlinjer)
Smart Guides (⌘U) Smarta stödlinjer (⌘U)
Smart Punctuation… Smarta skiljetecken…
Smart Punctuation Smarta skiljetecken
ff, fi, ffi Ligatures Ligaturer ff, fi, ffi
ff, fl, ffl Ligatures Ligaturer ff, fl, ffl
Smart Quotes Smarta citattecken
Smart Spaces Smarta blanksteg
En, Em Dashes Korta och långa tankstreck
Ellipses Ellipser
Expert Fractions Expertbråk
Replace In Ersätt i
Selected Text Only Endast markerad text
Entire Document Hela dokumentet
Report Results Rapportera resultat
Smooth Mjuk
Corner Hörn
Relative Relativ
Can't render this file because it is too large.
+12
View File
@@ -3239,6 +3239,18 @@ digits Malayalam Malayalam
Smart Guides (View → Smart Guides) Akıllı Kılavuzlar (Görünüm → Akıllı Kılavuzlar)
Smart Guides (⌘U) Akıllı Kılavuzlar (⌘U)
Smart Punctuation… Akıllı Noktalama…
Smart Punctuation Akıllı Noktalama
ff, fi, ffi Ligatures ff, fi, ffi Bitişik Harfleri
ff, fl, ffl Ligatures ff, fl, ffl Bitişik Harfleri
Smart Quotes Akıllı Tırnaklar
Smart Spaces Akıllı Boşluklar
En, Em Dashes En ve Em Tireler
Ellipses Üç Noktalar
Expert Fractions Uzman Kesirleri
Replace In Değiştirilecek Yer
Selected Text Only Yalnızca Seçili Metin
Entire Document Tüm Belge
Report Results Sonuçları Bildir
Smooth Pürüzsüz
Corner Köşe
Relative akraba
Can't render this file because it contains an unexpected character in line 5 and column 25.
+12
View File
@@ -3479,6 +3479,18 @@ effect Points Точки
Smart Guides (View → Smart Guides) Розумні напрямні (Перегляд → Розумні напрямні)
Smart Guides (⌘U) Розумні напрямні (⌘U)
Smart Punctuation… Розумна пунктуація…
Smart Punctuation Розумна пунктуація
ff, fi, ffi Ligatures Лігатури ff, fi, ffi
ff, fl, ffl Ligatures Лігатури ff, fl, ffl
Smart Quotes Розумні лапки
Smart Spaces Розумні пробіли
En, Em Dashes Середні й довгі тире
Ellipses Трикрапки
Expert Fractions Експертні дроби
Replace In Замінити в
Selected Text Only Тільки виділений текст
Entire Document Увесь документ
Report Results Звіт про результати
Smooth Згладити
Corner Кут
Relative Відносно
Can't render this file because it is too large.
+12
View File
@@ -3835,6 +3835,18 @@ mark-style Japanese Kiểu Nhật
Smart Guides (View → Smart Guides) Đường căn thông minh (Hiển thị → Đường căn thông minh)
Smart Guides (⌘U) Đường căn thông minh (⌘U)
Smart Punctuation… Dấu câu thông minh…
Smart Punctuation Dấu câu thông minh
ff, fi, ffi Ligatures Chữ ghép ff, fi, ffi
ff, fl, ffl Ligatures Chữ ghép ff, fl, ffl
Smart Quotes Dấu ngoặc kép thông minh
Smart Spaces Khoảng trắng thông minh
En, Em Dashes Gạch ngang ngắn và dài
Ellipses Dấu chấm lửng
Expert Fractions Phân số chuyên dụng
Replace In Thay thế trong
Selected Text Only Chỉ văn bản đã chọn
Entire Document Toàn bộ tài liệu
Report Results Báo cáo kết quả
Smooth Mượt
Smooth Color Màu mượt
Smooth Tool Công cụ Làm mượt
Can't render this file because it contains an unexpected character in line 204 and column 5.
+12
View File
@@ -3302,6 +3302,18 @@ digits Malayalam 马拉雅拉姆数字
Smart Guides (View → Smart Guides) 智能参考线 (视图 → 智能参考线)
Smart Guides (⌘U) 智能参考线 (⌘U)
Smart Punctuation… 智能标点…
Smart Punctuation 智能标点
ff, fi, ffi Ligatures ff、fi、ffi 连字
ff, fl, ffl Ligatures ff、fl、ffl 连字
Smart Quotes 智能引号
Smart Spaces 智能空格
En, Em Dashes 短破折号和长破折号
Ellipses 删节号
Expert Fractions 专家分数字
Replace In 替换范围
Selected Text Only 仅所选文本
Entire Document 整个文档
Report Results 报告结果
Smooth 平滑
Corner 尖角
Relative 相对
Can't render this file because it is too large.
+12
View File
@@ -4559,6 +4559,18 @@ digits Malayalam 馬來亞拉姆數字
Smart Guides (View → Smart Guides) 智慧型參考線 (檢視 → 智慧型參考線)
Smart Guides (⌘U) 智慧型參考線 (⌘U)
Smart Punctuation… 智慧型標點…
Smart Punctuation 智慧型標點
ff, fi, ffi Ligatures ff、fi、ffi 連字
ff, fl, ffl Ligatures ff、fl、ffl 連字
Smart Quotes 智慧型引號
Smart Spaces 智慧型空格
En, Em Dashes 短破折號和長破折號
Ellipses 刪節號
Expert Fractions 專家分數
Replace In 取代範圍
Selected Text Only 僅限選取的文字
Entire Document 整份文件
Report Results 報告結果
Smooth 平滑
Corner 角點
Relative 相對
Can't render this file because it is too large.
+2
View File
@@ -83,6 +83,8 @@ pub(super) fn menu_dialog(app: &VectorcraftApp, id: &str) -> Option<(&'static st
crate::addons::select::COMMAND => (crate::addons::select::KIND, crate::addons::select::fields(app)),
"artboard.rearrange" => (crate::dialogs::rearrange_artboards::KIND, crate::dialogs::rearrange_artboards::open_fields(app)),
"artboard.rename" => (crate::dialogs::rename_artboards::KIND, crate::dialogs::rename_artboards::open_fields(app)),
// Smart Punctuation opens on the fields it was last confirmed with.
"type.smartPunctuation" => (crate::dialogs::smart_punctuation::KIND, crate::dialogs::smart_punctuation::fields(app)),
_ => return None,
})
}
+1 -1
View File
@@ -436,7 +436,7 @@ pub fn menu_tree_named(english_names: bool) -> Vec<(&'static str, Vec<Item>)> {
cp("Sentence case", "type.changeCase", json!({"case": "sentence"})),
],
),
cp("Smart Punctuation…", "type.smartPunctuation", json!({"quotes": true, "dashes": true, "ellipsis": true, "scope": "selection"})),
c("Smart Punctuation…", "type.smartPunctuation"),
sub(
"Bullets and Numbering",
vec![
+4 -3
View File
@@ -379,14 +379,15 @@ mod tests {
)
}
/// A pick of a "…" command whose menu bar item gives params opens that item's dialog, and Smooth
/// opens its slider; nothing changes until the dialog is confirmed.
/// A pick of a "…" command whose menu bar item gives params opens that item's dialog, Smart
/// Punctuation opens its dialog and Smooth opens its slider; nothing changes until the dialog
/// is confirmed.
#[test]
fn a_pick_opens_the_dialog_its_menu_item_opens() {
let expected = [
("object.path.cleanUp", "command"),
("object.mesh.create", "command"),
("type.smartPunctuation", "command"),
("type.smartPunctuation", crate::dialogs::smart_punctuation::KIND),
("edit.findReplace", "command"),
("object.path.smooth", crate::dialogs::smooth_slider::KIND),
];
+2 -2
View File
@@ -297,8 +297,8 @@ fn a_shortcut_runs_what_its_menu_item_runs() {
/// Vector Halftone, Rearrange All Artboards, Pathfinder Options, the Object › Plug-ins dialogs
/// (Arrange in Grid, Replace with Top Object, the size, opacity and sort dialogs of the Arrange
/// add-on, Set Corners…, Divide into Dashes, Find Nearest Swatch, the swatch legend, the type
/// tools, the select add-on and Select by Link Status…), four "…" items whose menu entry gives
/// params, Edit Custom Dictionary…, Composite Fonts…, Recolor Artwork…, the Edit menu's preset
/// tools, the select add-on and Select by Link Status…), three "…" items whose menu entry gives
/// params, Smart Punctuation…, Edit Custom Dictionary…, Composite Fonts…, Recolor Artwork…, the Edit menu's preset
/// dialogs and Apply SVG Filter….
const MENU_DIALOG_COMMANDS: [&str; 39] = [
"object.path.smooth",
+4
View File
@@ -788,6 +788,9 @@ pub struct UiState {
/// dialog opens on them (#1152).
#[serde(default)]
pub offset_path: Value,
/// The Smart Punctuation fields confirmed last (null: never used): its dialog opens on them.
#[serde(default)]
pub smart_punctuation: Value,
/// The Average & Join fields confirmed last (`to`; null: never used): its dialog opens on them.
#[serde(default)]
pub average_join: Value,
@@ -1226,6 +1229,7 @@ impl Default for UiState {
dxf_options: Value::Null,
eps_options: Value::Null,
offset_path: Value::Null,
smart_punctuation: Value::Null,
average_join: Value::Null,
recolor_preserve: Value::Null,
simplify: Value::Null,
+27
View File
@@ -8612,6 +8612,33 @@ on again.
{"name":"run_command","arguments":{"command":"type.convertToAreaType","params":{"ids":[42]}}}
```
## Smart Punctuation
`type.smartPunctuation` replaces keyboard characters in the selected type, or in every text object with `scope:
"document"` or nothing selected, in one undo step. Each option is a switch:
- `fiLigatures` (default `false`): ff, fi and ffi become the ligature characters U+FB00, U+FB01 and U+FB03.
- `flLigatures` (default `false`): ff, fl and ffl become U+FB00, U+FB02 and U+FB04. The longest match is taken first.
- `quotes` (default `true`): straight quotes become the Document Setup quotes.
- `spaces` (default `false`): two or more spaces after a period become one.
- `dashes` (default `true`): `--` becomes an en dash and `---` an em dash.
- `ellipsis` (default `true`): `...` becomes an ellipsis.
- `fractions` (default `false`): 1/2, 1/4, 3/4 and the other fractions Unicode encodes as one character (thirds,
fifths, sixths, sevenths, eighths, ninths and 1/10) become that character. A fraction with a digit, a slash or a
decimal point next to it, as in 1/25, 1/2/26 or 1/2.5, is left as it is, also when a change of style falls inside
it. An inline graphic separates the text before it from the text after it, for this option and for `spaces`.
A ligature or a fraction is written only where the run's font has a glyph for it; elsewhere the letters stay. A value
other than true, false or null is refused. The reply gives the number of text objects changed and how many of each
replacement were made; with nothing to replace, no undo step is recorded. Type › Smart Punctuation… opens a dialog with
these options, Replace In (Selected Text Only or Entire Document) and Report Results, which lists the count of each
chosen replacement after OK. The dialog opens on the options confirmed last.
```json
{"name":"run_command","arguments":{"command":"type.smartPunctuation","params":{"fiLigatures":true,"spaces":true,"fractions":true}}}
→ {"changed": 1, "replaced": {"fiLigatures": 2, "flLigatures": 0, "quotes": 1, "spaces": 1, "dashes": 0, "ellipses": 0, "fractions": 2}}
```
## Hyphenation options
`text.setFormat` sets the Paragraph panel menu's Hyphenation… options of the selected type (or `ids`, or the
+1 -1
View File
@@ -51,7 +51,7 @@ against Illustrator's public documentation; **estimated** unless noted.
| Tab stops and leaders; Tabs panel | partial | Tabs panel and stops with leaders in the model (`text.tabs.set`); a stop drags from where the press landed (#1458); leaders fill the tab's gap, repeated on a grid so they line up from line to line (#1877); Ctrl-dragging a stop (Command on macOS) moves all the stops together; in right-aligned area type the text before a line's last tab sits at its stops, from the left edge, and the text after it against the right edge, as Illustrator's own layout in a user's `.ai` sets a price list (evidence: `tests::right_aligned_area_type_sets_the_text_after_its_last_tab_against_the_edge`; centred lines are still aligned as a whole); in justified area type the text up to a line's last tab keeps its spacing and its tabs their stops, and the text after the last tab takes the line's room to the far edge, VectorCraft's own rule (evidence: `tests::justify::a_justified_line_with_a_tab_spreads_the_text_after_it_to_the_edge` and the other tab tests in `crates/text/src/tests/justify.rs`) |
| Hidden characters (Show Hidden Characters) | done | `type.hiddenCharacters` |
| Spell check (Check Spelling, Auto Spell Check, custom dictionary) | partial | the engine (#4936): `text.spelling.check` lists the unknown words of the document's type, each run in its Language, at the bytes `text.editRange` changes, and `text.spelling.suggest` gives suggestions, both from craft-proof, each paragraph on its own (English from the first dictionary it finds: a Hunspell dictionary in the user's dictionaries folder, the SCOWL dictionary built in from craft-i18n, a system Hunspell dictionary, and last the public-domain Moby word list built into it; other languages from the dictionaries craft-proof finds for them). The custom dictionary commands are done: `text.spelling.addWord`, `removeWord` and `changeWord` (Add, and Edit Custom Dictionary's Add, Delete and Change), and `text.spelling.dictionary` lists the words, saved to `Custom Dictionary.txt` beside the preferences; Ignore All: `text.spelling.ignoreAll` skips a word in the active document while it is open. Auto Spell Check is done: Edit › Spelling › Auto Spell Check (`edit.autoSpellCheck`, off at first, saved with the view settings) draws a red wavy line under the unknown words of the visible type, leaves out type with effects, and follows edits, the custom dictionary and Ignore All. A right-click on an underlined word lists the words its dictionary suggests (each replaces it in one undo step, `text.editRange`), or No Suggestions, then Ignore All and Add to Dictionary, and a right-click on type has Spelling › Auto Spell Check, checked while it is on. Edit › Edit Custom Dictionary… lists the custom dictionary's words, with an Entry field and Add, Delete and Change, applied on Done (Cancel leaves the dictionary as it was). The Check Spelling dialog remains. Evidence: `crates/engine/src/tests/spelling.rs`, `crates/ui-egui/src/canvas/tests.rs` (`auto_spell_check_*`), `crates/ui-egui/src/tests/contextmenu.rs` (the right-click), `crates/ui-egui/src/dialogs/custom_dictionary.rs` (the dialog). |
| Smart Punctuation, Change Case, Find & Replace | done | |
| Smart Punctuation, Change Case, Find & Replace | done | Type › Smart Punctuation… opens a dialog with the ff, fi, ffi and ff, fl, ffl ligatures, Smart Quotes, Smart Spaces, En, Em Dashes, Ellipses and Expert Fractions, Replace In and Report Results, which lists the count of each replacement; ligatures and fractions are written only where the font has a glyph for them. Evidence: `tests::menucmds::smart_punctuation_ligatures_spaces_and_fractions_are_counted`, `smart_punctuation_skips_ligatures_and_fractions_the_font_lacks`, `smart_spaces_keeps_one_space_after_a_period`, `dialogs::smart_punctuation::tests::menu_item_opens_the_dialog_and_ok_reports_the_counts` |
| Alt + numeric-keypad codes while typing (Windows: `Alt+0176` → °) | partial | #5108: on Windows the character Windows posts when Alt comes up after keypad digits is typed at the caret like any other, in the typing's undo step, and the keypad digits typed with Alt run no shortcut. With NumLock off the keypad keys (Insert, End, arrows, Clear, Home, Page Up/Down without the extended-key flag) count as digits too and don't move the caret (`windows_alt_codes` unit tests; neither NumLock on nor off has been tried on a Windows machine yet). `type.insert {code}` (Windows Alt+0 code, Windows-1252 for 128–159) and `{unicode}` (hex code point) insert a character by its code (`menucmds::insert_a_character_by_its_code`). macOS and Linux have no such system convention and egui reports a keypad digit as the top-row digit, so there it does nothing; a floating panel window doesn't receive the character |
| Caret: the arrows and Delete step over whole clusters (Thai consonant with its marks, combining accents, emoji); Backspace removes one character | done | in text with right-to-left characters the arrows move in visual order and stop on both sides of a character drawn with no width, such as a zero width non-joiner |
| Touch Type tool | done | moves, scales and rotates one character through its kerning, baseline shift, scales and rotation (`text.touchType`); a character with a preceding logical character on the same line can move along the line in either reading direction; the first logical character moves only up and down. Positive `dx` follows reading order. These direction rules are VectorCraft's choices. |