mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Type: add OpenType Numerals submenu (figure styles)
Type › OpenType › Numerals sets lnum/onum/pnum/tnum as a radio style (Default through Tabular Oldstyle). Checkmarks follow the selection start; TYPE-218-5 scorecard/gaps updated; parity floor 640.
This commit is contained in:
1 parent
fd32d25270
commit
4e7d0c3f8a
10 files changed
+396
-13
No files matched your search
@@ -1,6 +1,7 @@
|
||||
//! The Type menu: anti-aliasing, orientation, point ⇄ paragraph conversion, Create Work Path,
|
||||
//! Convert to Shape, Rasterize, Warp Text, the OpenType toggles, Paste Lorem Ipsum, Update All
|
||||
//! Text Layers, missing-font replacement and the default type styles.
|
||||
//! Convert to Shape, Rasterize, Warp Text, the OpenType toggles (with the Numerals submenu),
|
||||
//! Paste Lorem Ipsum, Update All Text Layers, missing-font replacement and the default type
|
||||
//! styles.
|
||||
//!
|
||||
//! Everything edits the typed [`TextLayer`] model and re-renders through `type_cmds::refresh`,
|
||||
//! so the PSD `TySh` data (and with it warp, anti-aliasing and the OpenType flags) is regenerated
|
||||
@@ -502,6 +503,99 @@ fn warp_text(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
|
||||
// ---------- OpenType toggles ----------
|
||||
|
||||
/// OpenType figure tags Type › OpenType › Numerals clears or sets (`lnum`/`onum`/`pnum`/`tnum`).
|
||||
pub const NUMERAL_FEATURE_TAGS: [&str; 4] = ["lnum", "onum", "pnum", "tnum"];
|
||||
|
||||
/// One item of Type › OpenType › Numerals (Adobe figure-style radio set).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum NumeralsStyle {
|
||||
Default,
|
||||
Lining,
|
||||
Oldstyle,
|
||||
Proportional,
|
||||
Tabular,
|
||||
ProportionalLining,
|
||||
TabularLining,
|
||||
ProportionalOldstyle,
|
||||
TabularOldstyle,
|
||||
}
|
||||
|
||||
impl NumeralsStyle {
|
||||
/// Command-id suffix after `type.openType.numerals.`.
|
||||
pub const fn id(self) -> &'static str {
|
||||
match self {
|
||||
Self::Default => "default",
|
||||
Self::Lining => "lining",
|
||||
Self::Oldstyle => "oldstyle",
|
||||
Self::Proportional => "proportional",
|
||||
Self::Tabular => "tabular",
|
||||
Self::ProportionalLining => "proportionalLining",
|
||||
Self::TabularLining => "tabularLining",
|
||||
Self::ProportionalOldstyle => "proportionalOldstyle",
|
||||
Self::TabularOldstyle => "tabularOldstyle",
|
||||
}
|
||||
}
|
||||
|
||||
/// Menu label for this numerals style.
|
||||
pub const fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::Default => "Default",
|
||||
Self::Lining => "Lining",
|
||||
Self::Oldstyle => "Oldstyle",
|
||||
Self::Proportional => "Proportional",
|
||||
Self::Tabular => "Tabular",
|
||||
Self::ProportionalLining => "Proportional Lining",
|
||||
Self::TabularLining => "Tabular Lining",
|
||||
Self::ProportionalOldstyle => "Proportional Oldstyle",
|
||||
Self::TabularOldstyle => "Tabular Oldstyle",
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse a `type.openType.numerals.*` suffix.
|
||||
pub fn from_id(id: &str) -> Option<Self> {
|
||||
Some(match id {
|
||||
"default" => Self::Default,
|
||||
"lining" => Self::Lining,
|
||||
"oldstyle" => Self::Oldstyle,
|
||||
"proportional" => Self::Proportional,
|
||||
"tabular" => Self::Tabular,
|
||||
"proportionalLining" => Self::ProportionalLining,
|
||||
"tabularLining" => Self::TabularLining,
|
||||
"proportionalOldstyle" => Self::ProportionalOldstyle,
|
||||
"tabularOldstyle" => Self::TabularOldstyle,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Every Numerals menu item, in menu order.
|
||||
pub const ALL: [Self; 9] = [
|
||||
Self::Default,
|
||||
Self::Lining,
|
||||
Self::Oldstyle,
|
||||
Self::Proportional,
|
||||
Self::Tabular,
|
||||
Self::ProportionalLining,
|
||||
Self::TabularLining,
|
||||
Self::ProportionalOldstyle,
|
||||
Self::TabularOldstyle,
|
||||
];
|
||||
|
||||
/// OpenType tags this style turns on (the other [`NUMERAL_FEATURE_TAGS`] are cleared).
|
||||
pub const fn tags(self) -> &'static [&'static str] {
|
||||
match self {
|
||||
Self::Default => &[],
|
||||
Self::Lining => &["lnum"],
|
||||
Self::Oldstyle => &["onum"],
|
||||
Self::Proportional => &["pnum"],
|
||||
Self::Tabular => &["tnum"],
|
||||
Self::ProportionalLining => &["pnum", "lnum"],
|
||||
Self::TabularLining => &["tnum", "lnum"],
|
||||
Self::ProportionalOldstyle => &["pnum", "onum"],
|
||||
Self::TabularOldstyle => &["tnum", "onum"],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Is the OpenType toggle `tag` on for a character style? (`liga`/`dlig` have dedicated fields.)
|
||||
pub fn feature_on(st: &photocraft_doc::text::CharStyle, tag: &str) -> bool {
|
||||
match tag {
|
||||
@@ -511,6 +605,43 @@ pub fn feature_on(st: &photocraft_doc::text::CharStyle, tag: &str) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Is the OpenType toggle `tag` on at character `ci` of `t`? Past the end it reads the last run.
|
||||
pub fn feature_on_at(t: &TextLayer, ci: usize, tag: &str) -> bool {
|
||||
let at = byte_index(&t.text, ci);
|
||||
let runs = t.char_runs();
|
||||
let mut end = 0usize;
|
||||
let run = runs.iter().find(|r| {
|
||||
end = end.saturating_add(r.len);
|
||||
at < end
|
||||
});
|
||||
run.or(runs.last()).is_some_and(|r| feature_on(&r.style, tag))
|
||||
}
|
||||
|
||||
/// Which Numerals menu item matches `st`'s figure tags? `None` when the mix is not a menu item.
|
||||
pub fn numerals_style_of(st: &photocraft_doc::text::CharStyle) -> Option<NumeralsStyle> {
|
||||
let on = |tag: &str| feature_on(st, tag);
|
||||
let (lnum, onum, pnum, tnum) = (on("lnum"), on("onum"), on("pnum"), on("tnum"));
|
||||
NumeralsStyle::ALL.into_iter().find(|style| {
|
||||
let tags = style.tags();
|
||||
(lnum == tags.contains(&"lnum"))
|
||||
&& (onum == tags.contains(&"onum"))
|
||||
&& (pnum == tags.contains(&"pnum"))
|
||||
&& (tnum == tags.contains(&"tnum"))
|
||||
})
|
||||
}
|
||||
|
||||
/// Numerals style at character `ci` of `t` (same run pick as [`feature_on_at`]).
|
||||
pub fn numerals_style_at(t: &TextLayer, ci: usize) -> Option<NumeralsStyle> {
|
||||
let at = byte_index(&t.text, ci);
|
||||
let runs = t.char_runs();
|
||||
let mut end = 0usize;
|
||||
let run = runs.iter().find(|r| {
|
||||
end = end.saturating_add(r.len);
|
||||
at < end
|
||||
});
|
||||
run.or(runs.last()).and_then(|r| numerals_style_of(&r.style))
|
||||
}
|
||||
|
||||
fn set_feature(st: &mut photocraft_doc::text::CharStyle, tag: &str, on: bool) {
|
||||
match tag {
|
||||
"liga" => st.ligatures = on,
|
||||
@@ -524,13 +655,39 @@ fn set_feature(st: &mut photocraft_doc::text::CharStyle, tag: &str, on: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_numerals(st: &mut photocraft_doc::text::CharStyle, style: NumeralsStyle) {
|
||||
let on = style.tags();
|
||||
for tag in NUMERAL_FEATURE_TAGS {
|
||||
set_feature(st, tag, on.contains(&tag));
|
||||
}
|
||||
}
|
||||
|
||||
fn set_numerals(s: &mut Session, p: &Value, style: NumeralsStyle) -> Result<Value> {
|
||||
with_text_targets(s, p, "Change OpenType Numerals", |t, (a, b)| {
|
||||
style_range(t, a.min(b), a.max(b), &|st| apply_numerals(st, style));
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(json!({"numerals": style.id()}))
|
||||
}
|
||||
|
||||
fn toggle_opentype(s: &mut Session, p: &Value, tag: &'static str) -> Result<Value> {
|
||||
let ids = format_targets(s, p)?;
|
||||
let st = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let representative = st.active_layer.filter(|id| ids.contains(id)).or_else(|| ids.first().copied());
|
||||
// The toggle direction follows the style where the edit starts: the range start on a single
|
||||
// layer, else the first character.
|
||||
let start_char = if p.get("layers").is_none() || p.get("layer").is_some() {
|
||||
p.get("range").and_then(Value::as_array).filter(|r| r.len() == 2).map_or(0, |r| {
|
||||
let a = r.first().and_then(Value::as_u64).unwrap_or(0);
|
||||
let b = r.get(1).and_then(Value::as_u64).unwrap_or(a);
|
||||
usize::try_from(a.min(b)).unwrap_or(usize::MAX)
|
||||
})
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let cur = representative
|
||||
.and_then(|id| st.doc.layer(id))
|
||||
.is_some_and(|l| matches!(&l.content, LayerContent::Text(t) if t.char_runs().first().is_some_and(|r| feature_on(&r.style, tag))));
|
||||
.is_some_and(|l| matches!(&l.content, LayerContent::Text(t) if feature_on_at(t, start_char, tag)));
|
||||
let on = p.get("on").and_then(Value::as_bool).unwrap_or(!cur);
|
||||
with_text_targets(s, p, "Change OpenType Feature", |t, (a, b)| {
|
||||
style_range(t, a.min(b), a.max(b), &|st| set_feature(st, tag, on));
|
||||
@@ -770,6 +927,63 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
spec!("type.openType.ornaments", "Ornaments", &["Type", "OpenType"], OT, has_format_target, |s, p| toggle_opentype(s, p, "ornm")),
|
||||
spec!("type.openType.ordinals", "Ordinals", &["Type", "OpenType"], OT, has_format_target, |s, p| toggle_opentype(s, p, "ordn")),
|
||||
spec!("type.openType.fractions", "Fractions", &["Type", "OpenType"], OT, has_format_target, |s, p| toggle_opentype(s, p, "frac")),
|
||||
spec!(
|
||||
"type.openType.numerals.default",
|
||||
"Default",
|
||||
&["Type", "OpenType", "Numerals"],
|
||||
FP,
|
||||
has_format_target,
|
||||
|s, p| set_numerals(s, p, NumeralsStyle::Default)
|
||||
),
|
||||
spec!("type.openType.numerals.lining", "Lining", &["Type", "OpenType", "Numerals"], FP, has_format_target, |s, p| {
|
||||
set_numerals(s, p, NumeralsStyle::Lining)
|
||||
}),
|
||||
spec!("type.openType.numerals.oldstyle", "Oldstyle", &["Type", "OpenType", "Numerals"], FP, has_format_target, |s, p| {
|
||||
set_numerals(s, p, NumeralsStyle::Oldstyle)
|
||||
}),
|
||||
spec!(
|
||||
"type.openType.numerals.proportional",
|
||||
"Proportional",
|
||||
&["Type", "OpenType", "Numerals"],
|
||||
FP,
|
||||
has_format_target,
|
||||
|s, p| set_numerals(s, p, NumeralsStyle::Proportional)
|
||||
),
|
||||
spec!("type.openType.numerals.tabular", "Tabular", &["Type", "OpenType", "Numerals"], FP, has_format_target, |s, p| {
|
||||
set_numerals(s, p, NumeralsStyle::Tabular)
|
||||
}),
|
||||
spec!(
|
||||
"type.openType.numerals.proportionalLining",
|
||||
"Proportional Lining",
|
||||
&["Type", "OpenType", "Numerals"],
|
||||
FP,
|
||||
has_format_target,
|
||||
|s, p| set_numerals(s, p, NumeralsStyle::ProportionalLining)
|
||||
),
|
||||
spec!(
|
||||
"type.openType.numerals.tabularLining",
|
||||
"Tabular Lining",
|
||||
&["Type", "OpenType", "Numerals"],
|
||||
FP,
|
||||
has_format_target,
|
||||
|s, p| set_numerals(s, p, NumeralsStyle::TabularLining)
|
||||
),
|
||||
spec!(
|
||||
"type.openType.numerals.proportionalOldstyle",
|
||||
"Proportional Oldstyle",
|
||||
&["Type", "OpenType", "Numerals"],
|
||||
FP,
|
||||
has_format_target,
|
||||
|s, p| set_numerals(s, p, NumeralsStyle::ProportionalOldstyle)
|
||||
),
|
||||
spec!(
|
||||
"type.openType.numerals.tabularOldstyle",
|
||||
"Tabular Oldstyle",
|
||||
&["Type", "OpenType", "Numerals"],
|
||||
FP,
|
||||
has_format_target,
|
||||
|s, p| set_numerals(s, p, NumeralsStyle::TabularOldstyle)
|
||||
),
|
||||
spec!("type.createWorkPath", "Create Work Path", &["Type"], LP, has_text, create_work_path),
|
||||
spec!("type.convertToShape", "Convert to Shape", &["Type"], LP, has_text, convert_to_shape),
|
||||
spec!("type.rasterizeTypeLayer", "Rasterize Type Layer", &["Type"], LP, has_text, |s, p| s.execute("type.rasterize", p.clone())),
|
||||
|
||||
@@ -243,6 +243,138 @@ fn opentype_toggles_store_features() {
|
||||
assert!(feature_on(&back.char_runs()[0].style, "swsh") && !back.char_runs()[0].style.ligatures);
|
||||
}
|
||||
|
||||
/// Is `tag` on at character `ci` of an ASCII text layer?
|
||||
fn on_at(s: &Session, id: LayerId, ci: usize, tag: &str) -> bool {
|
||||
let mut end = 0;
|
||||
text(s, id)
|
||||
.char_runs()
|
||||
.iter()
|
||||
.find(|r| {
|
||||
end += r.len;
|
||||
ci < end
|
||||
})
|
||||
.is_some_and(|r| feature_on(&r.style, tag))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numerals_are_registered_with_their_menu_path() {
|
||||
for style in NumeralsStyle::ALL {
|
||||
let spec = crate::commands::find(&format!("type.openType.numerals.{}", style.id())).unwrap();
|
||||
assert_eq!(spec.label, style.label());
|
||||
assert_eq!(spec.menu, ["Type", "OpenType", "Numerals"]);
|
||||
}
|
||||
assert!(crate::commands::find("type.openType.numerals.unknown").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numerals_replace_figure_tags_and_keep_other_features() {
|
||||
let mut s = session(8);
|
||||
let id = text_layer(&mut s, "012345");
|
||||
let before = text(&s, id).char_runs()[0].style.clone();
|
||||
s.execute("type.openType.fractions", json!({"on": true})).unwrap();
|
||||
s.execute("type.openType.numerals.tabularLining", json!({})).unwrap();
|
||||
assert_eq!(numerals_style_of(&text(&s, id).char_runs()[0].style), Some(NumeralsStyle::TabularLining));
|
||||
assert!(on_at(&s, id, 0, "tnum") && on_at(&s, id, 0, "lnum") && !on_at(&s, id, 0, "onum") && !on_at(&s, id, 0, "pnum"));
|
||||
assert!(feature_on(&text(&s, id).char_runs()[0].style, "frac"), "non-figure features stay");
|
||||
s.execute("type.openType.numerals.proportionalOldstyle", json!({})).unwrap();
|
||||
assert_eq!(numerals_style_of(&text(&s, id).char_runs()[0].style), Some(NumeralsStyle::ProportionalOldstyle));
|
||||
assert!(on_at(&s, id, 0, "pnum") && on_at(&s, id, 0, "onum") && !on_at(&s, id, 0, "tnum") && !on_at(&s, id, 0, "lnum"));
|
||||
s.execute("type.openType.numerals.default", json!({})).unwrap();
|
||||
assert_eq!(numerals_style_of(&text(&s, id).char_runs()[0].style), Some(NumeralsStyle::Default));
|
||||
for tag in NUMERAL_FEATURE_TAGS {
|
||||
assert!(!on_at(&s, id, 0, tag), "{tag}");
|
||||
}
|
||||
let st = text(&s, id).char_runs()[0].style.clone();
|
||||
assert!(st.ligatures, "liga untouched");
|
||||
assert_eq!((st.size_pt, st.font_family.clone(), st.color), (before.size_pt, before.font_family, before.color));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numerals_range_edits_only_those_characters() {
|
||||
let mut s = session(8);
|
||||
let id = text_layer(&mut s, "abcdef");
|
||||
s.execute("type.openType.numerals.lining", json!({"range": [2, 5]})).unwrap();
|
||||
let on: Vec<bool> = (0..6).map(|i| on_at(&s, id, i, "lnum")).collect();
|
||||
assert_eq!(on, [false, false, true, true, true, false]);
|
||||
assert_eq!(numerals_style_at(text(&s, id), 2), Some(NumeralsStyle::Lining));
|
||||
assert_eq!(numerals_style_at(text(&s, id), 0), Some(NumeralsStyle::Default));
|
||||
s.execute("type.openType.numerals.tabular", json!({"range": [2, 5]})).unwrap();
|
||||
assert!(on_at(&s, id, 3, "tnum") && !on_at(&s, id, 3, "lnum"));
|
||||
assert!(!on_at(&s, id, 0, "tnum"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numerals_apply_to_every_listed_layer() {
|
||||
let mut s = session(8);
|
||||
let a = text_layer(&mut s, "one");
|
||||
let b = text_layer(&mut s, "two");
|
||||
s.execute("type.openType.numerals.oldstyle", json!({"layers": [a.0, b.0]})).unwrap();
|
||||
assert!(on_at(&s, a, 0, "onum") && on_at(&s, b, 2, "onum"));
|
||||
s.execute("type.openType.numerals.default", json!({"layers": [a.0, b.0]})).unwrap();
|
||||
assert!(!on_at(&s, a, 0, "onum") && !on_at(&s, b, 0, "onum"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numerals_are_one_undo_step_each() {
|
||||
let mut s = session(8);
|
||||
let id = text_layer(&mut s, "123");
|
||||
s.execute("type.openType.numerals.lining", json!({})).unwrap();
|
||||
s.execute("type.openType.numerals.tabularOldstyle", json!({})).unwrap();
|
||||
assert!(s.undo());
|
||||
assert_eq!(numerals_style_of(&text(&s, id).char_runs()[0].style), Some(NumeralsStyle::Lining));
|
||||
assert!(s.undo());
|
||||
assert_eq!(numerals_style_of(&text(&s, id).char_runs()[0].style), Some(NumeralsStyle::Default));
|
||||
assert!(s.redo());
|
||||
assert_eq!(numerals_style_of(&text(&s, id).char_runs()[0].style), Some(NumeralsStyle::Lining));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numerals_survive_a_pcraft_round_trip() {
|
||||
let mut s = session(8);
|
||||
let id = text_layer(&mut s, "Il36");
|
||||
s.execute("type.openType.numerals.proportionalLining", json!({})).unwrap();
|
||||
let bytes = photocraft_format::save_to_bytes(&s.active().unwrap().doc, &Default::default()).unwrap();
|
||||
let doc = photocraft_format::load_from_bytes(&bytes).unwrap();
|
||||
let Some(LayerContent::Text(t)) = doc.layer(id).map(|l| &l.content) else { panic!("text layer lost") };
|
||||
assert_eq!(numerals_style_of(&t.char_runs()[0].style), Some(NumeralsStyle::ProportionalLining));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numerals_fail_gracefully_on_bad_params() {
|
||||
let mut s = session(8);
|
||||
let bg = s.active().unwrap().active_layer.unwrap();
|
||||
let id = text_layer(&mut s, "abc");
|
||||
let cmd = "type.openType.numerals.tabularLining";
|
||||
assert!(s.execute(cmd, json!({"layer": 987_654})).is_err(), "unknown layer");
|
||||
assert!(s.execute(cmd, json!({"layer": bg.0})).is_err(), "not a type layer");
|
||||
assert!(s.execute(cmd, json!({"layers": ["x"]})).is_err());
|
||||
s.execute(cmd, json!({"range": [5, 2]})).unwrap();
|
||||
s.execute(cmd, json!({"range": [50, 90]})).unwrap();
|
||||
s.execute(cmd, json!({"range": [u64::MAX, 0]})).unwrap();
|
||||
s.execute(cmd, json!({"range": "all"})).unwrap();
|
||||
assert!(s.execute(cmd, json!({"layer": id.0, "range": [0, 1]})).is_ok());
|
||||
assert_eq!(numerals_style_of(&text(&s, id).char_runs()[0].style), Some(NumeralsStyle::TabularLining));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numerals_tabular_changes_inter_digit_widths() {
|
||||
let mut s = session(8);
|
||||
let r = s.execute("type.create", json!({"x": 20, "y": 70, "text": "1111111111", "font": "Inter", "size": 36, "color": "#000000"})).unwrap();
|
||||
let id = LayerId(r["layer"].as_u64().unwrap());
|
||||
let width = |s: &Session| {
|
||||
let t = text(s, id).clone();
|
||||
let mut e = photocraft_text::shared().lock().unwrap_or_else(|e| e.into_inner());
|
||||
let layout = e.layout(&t, 72.0);
|
||||
layout.lines.first().map_or(0.0, |line| line.x1 - line.x0)
|
||||
};
|
||||
let plain = width(&s);
|
||||
s.execute("type.openType.numerals.tabular", json!({})).unwrap();
|
||||
let tab = width(&s);
|
||||
assert!((tab - plain).abs() > 0.5, "tnum changes Inter's digit advances: {plain} → {tab}");
|
||||
s.execute("type.openType.numerals.default", json!({})).unwrap();
|
||||
assert!((width(&s) - plain).abs() < 0.5, "default restores the advances");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lorem_update_fonts_and_default_styles() {
|
||||
let mut s = session(16);
|
||||
|
||||
@@ -474,6 +474,15 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[
|
||||
(&["Type", "OpenType"], "Ornaments", None, "type.openType.ornaments"),
|
||||
(&["Type", "OpenType"], "Ordinals", None, "type.openType.ordinals"),
|
||||
(&["Type", "OpenType"], "Fractions", None, "type.openType.fractions"),
|
||||
(&["Type", "OpenType", "Numerals"], "Default", None, "type.openType.numerals.default"),
|
||||
(&["Type", "OpenType", "Numerals"], "Lining", None, "type.openType.numerals.lining"),
|
||||
(&["Type", "OpenType", "Numerals"], "Oldstyle", None, "type.openType.numerals.oldstyle"),
|
||||
(&["Type", "OpenType", "Numerals"], "Proportional", None, "type.openType.numerals.proportional"),
|
||||
(&["Type", "OpenType", "Numerals"], "Tabular", None, "type.openType.numerals.tabular"),
|
||||
(&["Type", "OpenType", "Numerals"], "Proportional Lining", None, "type.openType.numerals.proportionalLining"),
|
||||
(&["Type", "OpenType", "Numerals"], "Tabular Lining", None, "type.openType.numerals.tabularLining"),
|
||||
(&["Type", "OpenType", "Numerals"], "Proportional Oldstyle", None, "type.openType.numerals.proportionalOldstyle"),
|
||||
(&["Type", "OpenType", "Numerals"], "Tabular Oldstyle", None, "type.openType.numerals.tabularOldstyle"),
|
||||
(&["Type"], "---", None, "---"),
|
||||
(&["Type"], "Create Work Path", None, "type.createWorkPath"),
|
||||
(&["Type"], "Convert to Shape", None, "type.convertToShape"),
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::menu_catalog::CATALOG;
|
||||
use crate::menus::is_live;
|
||||
|
||||
/// Minimum number of live catalog items. Raise it when parity grows; never lower it.
|
||||
pub const FLOOR: usize = 631;
|
||||
pub const FLOOR: usize = 640;
|
||||
|
||||
/// One top-level menu's coverage.
|
||||
#[derive(Clone, Debug, serde::Serialize)]
|
||||
|
||||
@@ -185,6 +185,13 @@ fn type_checked(app: &PhotocraftApp, id: &str) -> Option<bool> {
|
||||
return Some(t.is_some_and(|t| (t.orientation == photocraft_doc::text::Orientation::Vertical) == (k == "vertical")));
|
||||
}
|
||||
let t = t?;
|
||||
// The style where the menu reads: the selection start while editing a range (as the Character
|
||||
// panel shows it), else the layer's first run.
|
||||
let start = crate::type_tool::target(app).and_then(|(_, range)| range).map_or(0, |r| r[0]);
|
||||
if let Some(key) = id.strip_prefix("type.openType.numerals.") {
|
||||
let want = photocraft_engine::type_extra_cmds::NumeralsStyle::from_id(key)?;
|
||||
return Some(photocraft_engine::type_extra_cmds::numerals_style_at(t, start) == Some(want));
|
||||
}
|
||||
let tag = match id.strip_prefix("type.openType.")? {
|
||||
"standardLigatures" => "liga",
|
||||
"contextualAlternates" => "calt",
|
||||
@@ -198,7 +205,7 @@ fn type_checked(app: &PhotocraftApp, id: &str) -> Option<bool> {
|
||||
"fractions" => "frac",
|
||||
_ => return None,
|
||||
};
|
||||
Some(t.char_runs().first().is_some_and(|r| photocraft_engine::type_extra_cmds::feature_on(&r.style, tag)))
|
||||
Some(photocraft_engine::type_extra_cmds::feature_on_at(t, start, tag))
|
||||
}
|
||||
|
||||
/// Engine commands that get a dialog or file picker here when invoked without parameters.
|
||||
|
||||
@@ -255,6 +255,26 @@ fn type_menu_checkmarks_follow_the_layer() {
|
||||
assert_eq!(checked(&app, "type.orientation.horizontal"), Some(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numerals_checkmark_follows_the_selection() {
|
||||
let (mut app, ctx) = app_with(1);
|
||||
let id = "type.openType.numerals.tabularLining";
|
||||
assert!(!crate::menus::is_enabled(&app, id));
|
||||
assert_eq!(checked(&app, id), None, "no type layer");
|
||||
app.run("type.create", json!({"x": 10, "y": 50, "text": "Type", "size": 24})).unwrap();
|
||||
assert!(crate::menus::is_enabled(&app, id));
|
||||
assert_eq!(checked(&app, "type.openType.numerals.default"), Some(true));
|
||||
assert_eq!(checked(&app, id), Some(false));
|
||||
menu(&mut app, &ctx, id, json!({})).unwrap();
|
||||
assert_eq!(checked(&app, id), Some(true));
|
||||
assert_eq!(checked(&app, "type.openType.numerals.default"), Some(false));
|
||||
assert_eq!(checked(&app, "type.openType.numerals.lining"), Some(false));
|
||||
menu(&mut app, &ctx, "type.openType.numerals.default", json!({})).unwrap();
|
||||
assert_eq!(checked(&app, "type.openType.numerals.default"), Some(true));
|
||||
assert_eq!(checked(&app, id), Some(false));
|
||||
assert_eq!(checked(&app, "type.openType.numerals.notAStyle"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn batch_menu_requires_a_recorded_action() {
|
||||
let (mut app, ctx) = app_with(1);
|
||||
|
||||
+3
-2
@@ -99,8 +99,8 @@ what an agent can't finish alone.
|
||||
and saves back into the file's `Txt2` since 2026-10-21, #7962),
|
||||
the visual RTL caret and PSD storage of the paragraph direction (TYPE-218-2; the paragraph
|
||||
direction buttons landed 2026-10-22), complex-script fallback fonts and golden tests
|
||||
(TYPE-218-3), OpenType Numerals and Stylistic Sets submenus
|
||||
(TYPE-218-5; the Character panel buttons landed 2026-10-11, #3752), text free transform
|
||||
(TYPE-218-3), OpenType Stylistic Sets submenu and greying out features the font lacks
|
||||
(TYPE-218-5; Character panel buttons 2026-10-11, #3752; Numerals submenu 2026-11-03), text free transform
|
||||
(#2630), area type in PSD (TYPE-218-10). Done since the re-measure: manual and optical kerning with PSD round trip
|
||||
(TYPE-218-6, #206), variable-font axes (TYPE-218-4, #2985), Warp on live type without a
|
||||
rasterize prompt, as in Photoshop (TYPE-218-9, #3004), and the live Warp Text preview that opens
|
||||
@@ -527,6 +527,7 @@ what an agent can't finish alone.
|
||||
| 2026-10-11 | minor | G13: Czech dynamic UI text localized; engine messages and native review remain open |
|
||||
| 2026-10-11 | minor | G8: triple/quadruple/five-click type selection done (TYPE-218-8, #3493); Type evidence recounted |
|
||||
| 2026-10-11 | minor | G4: Pattern Stamp and Background Eraser draw live, Spot Healing shows a dark overlay while dragging (#3754); only the Mixer Brush is left of TOOL-213-7 |
|
||||
| 2026-11-03 | minor | G8: Type › OpenType › Numerals submenu landed (TYPE-218-5); Stylistic Sets and font-feature greying still missing |
|
||||
| 2026-10-11 | minor | G8: Character panel OpenType buttons landed (TYPE-218-5, #3752); Numerals and Stylistic Sets submenus still missing |
|
||||
| 2026-10-11 | minor | G10: one-page flattened PDF write shipped (io::pdf, #3401); FILE-215-10 now partial |
|
||||
| 2026-10-10 | minor | G2: recorded Tilt-Shift computation/filtered-proxy measurements and limits; gap and estimate remain open
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Generated by `cargo xtask parity` from `crates/ui-egui/src/menu_catalog.rs` (Photoshop's menu tree) and the live command registry. Do not edit by hand.
|
||||
|
||||
**631 of 631 menu items live (100.0%).**
|
||||
**640 of 640 menu items live (100.0%).**
|
||||
|
||||
| Menu | Live | Total | % |
|
||||
|---|---:|---:|---:|
|
||||
@@ -10,7 +10,7 @@ Generated by `cargo xtask parity` from `crates/ui-egui/src/menu_catalog.rs` (Pho
|
||||
| Edit | 75 | 75 | 100% |
|
||||
| Image | 61 | 61 | 100% |
|
||||
| Layer | 163 | 163 | 100% |
|
||||
| Type | 45 | 45 | 100% |
|
||||
| Type | 54 | 54 | 100% |
|
||||
| Select | 25 | 25 | 100% |
|
||||
| Filter | 75 | 75 | 100% |
|
||||
| View | 74 | 74 | 100% |
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js
|
||||
| [Tools](#tools) | 36 | 9 | 0 | |
|
||||
| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 10 of 186 (target 0) |
|
||||
| [Type](#type) | 5 | 5 | 0 | |
|
||||
| [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) |
|
||||
| [Automation](#automation) | 5 | 2 | 4 | 640 of 640 menu items live (100.0%) |
|
||||
| [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 30 of 30 crates; panic_hunt present |
|
||||
| [Distribution](#distribution) | 5 | 5 | 1 | |
|
||||
| [Open bugs](#open-bugs) | 31 | 1 | 0 | |
|
||||
@@ -241,7 +241,7 @@ Unread: `general.color_picker`, `workspace.auto_show_hidden_panels`, `workspace.
|
||||
| TYPE-218-2 | Paragraph direction (Auto/LTR/RTL) in the panel and options bar; visual RTL caret | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Paragraph section (Window > Paragraph and Properties) and the options bar have Auto / Left-to-right / Right-to-left buttons setting the paragraph direction through type.setStyle; the options bar's choice is also the direction new type starts with (type_tool.rs direction_items; paragraph_direction_buttons_set_and_show_the_direction, options_bar_direction_sets_selected_layers_and_new_type). Still missing: visual RTL caret (the arrow keys move in logical order), and PSD doesn't store the direction (crates/text psd.rs neither reads nor writes it, so it reopens as Auto) |
|
||||
| TYPE-218-3 | Thai/Khmer/Indic fallback fonts; golden shaping tests for complex scripts and RTL | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Fallback fonts are covered for Thai, Khmer, Lao, Myanmar (THAI_FAMILIES, KHMER_FAMILIES, LAO_FAMILIES, MYANMAR_FAMILIES in fonts.rs; #1909, #3259), the nine Indic scripts (INDIC_FAMILIES: Nirmala UI, Kohinoor and Sangam MN, Noto Sans) and Arabic and Hebrew. Still missing: per-script golden shaping tests against reference output (only smoke tests that an installed font shapes without .notdef, plus a bidi test) |
|
||||
| TYPE-218-4 | Variable font axis sliders from the font's axes; opsz follows the point size | done | [#218](https://github.com/storytold/photocraft/issues/218) | One slider per axis of the style's font in the Character section (Properties and Window > Character), setting type.setStyle variations; opsz follows the type size unless set (layout.rs variation_list); a style or weight resets the wght axis (#2985). PSD does not round-trip axis values yet |
|
||||
| TYPE-218-5 | OpenType UI: Character panel buttons, Numerals and Stylistic Sets submenus | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Type > OpenType toggles (type_extra_cmds.rs:512). Character panel (and the Properties Character section) has Photoshop's eight OpenType buttons: Standard Ligatures, Contextual Alternates, Discretionary Ligatures, Swash, Stylistic Alternates, Titling Alternates, Ordinals, Fractions, pressed while the feature is on at the selection and dispatching the type.openType.* commands (type_tool.rs opentype_row; character_panel_opentype_buttons_toggle_and_show_the_feature, #3752). Still missing: the Numerals and Stylistic Sets submenus, and greying out features the font lacks |
|
||||
| TYPE-218-5 | OpenType UI: Character panel buttons, Numerals and Stylistic Sets submenus | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Type > OpenType toggles (type_extra_cmds.rs). Character panel (and the Properties Character section) has Photoshop's eight OpenType buttons: Standard Ligatures, Contextual Alternates, Discretionary Ligatures, Swash, Stylistic Alternates, Titling Alternates, Ordinals, Fractions, pressed while the feature is on at the selection and dispatching the type.openType.* commands (type_tool.rs opentype_row; character_panel_opentype_buttons_toggle_and_show_the_feature, #3752). Type > OpenType > Numerals (Default, Lining, Oldstyle, Proportional, Tabular, and the four height×width combinations) landed 2026-11-03: each sets lnum/onum/pnum/tnum as a radio style on the selection or layer, round-trips .pcraft, and shows its checkmark from the style at the selection start. Still missing: the Stylistic Sets submenu, and greying out features the font lacks |
|
||||
| TYPE-218-6 | Manual pair kerning (Alt+arrows), optical kerning rendered, both round-trip PSD (#206) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Alt+Left/Right at a collapsed caret kerns the pair (type_tool.rs kern_pair, 20 per step and 100 with Cmd; type_tool_alt_arrows_kern_the_pair). Optical kerning is computed from the glyph outlines in text/src/optical.rs and applied by layout.rs when the run's mode is Optical (optical_matches_photoshop, optical_kerning_tightens_open_pairs). Both modes and manual values round-trip through PSD (io/tests/it/psd_kerning.rs; the optical mode travels in Txt2, txt2_carries_optical_kerning) |
|
||||
| TYPE-218-7 | Warp Text dialog previews live and opens with the layer's current warp | done | [#218](https://github.com/storytold/photocraft/issues/218) | Type > Warp Text opens with the shown layer's warp, or None, never remembered values (filter_dialog.rs:503 warp_defaults; warp_text_dialog_tests.rs:80 warp_text_opens_with_the_type_layers_current_warp, :99 warp_text_opens_at_none_for_a_layer_without_warp, :108 remembered_warp_values_never_override_the_layers_warp). The dialog previews live without editing the document, Cancel leaves no step and OK is one undoable step (:138 warp_text_dialog_previews_the_warp_without_editing_the_document, :160 cancelling_warp_text_leaves_the_document_and_history_untouched, :179 confirming_warp_text_is_one_undoable_step); the reduced-proxy preview matches the full-size result (filter_dialog.rs:2150 warp_text_preview_matches_the_full_size_result_on_a_reduced_proxy) |
|
||||
| TYPE-218-8 | Text editing: select all, double/triple/quadruple-click selection, paste, with tests | done | [#218](https://github.com/storytold/photocraft/issues/218) | Like Photoshop, 2 clicks select the word, 3 the laid-out line (a column in vertical type), 4 the paragraph up to the hard return, 5 all text, and the next quick click starts over (#3493; type_tool.rs next_click_count, click_selection, multi_click). Tested through real canvas clicks in point, paragraph and vertical type, with paste replacing the selection and Cmd+A selecting all (type_tool_tests.rs multi_click_selects_word_line_paragraph_and_all_in_point_text, multi_click_separates_wrapped_lines_from_paragraphs, click_counts_cycle_and_restart, click_selection_without_layout_and_on_hostile_input, multi_click_without_a_session_does_nothing) |
|
||||
@@ -250,7 +250,7 @@ Unread: `general.color_picker`, `workspace.auto_show_hidden_panels`, `workspace.
|
||||
|
||||
## Automation
|
||||
|
||||
Menu wiring (`docs/parity-checklist.md`): 631 of 631 menu items live (100.0%). This counts dispatch, not behaviour.
|
||||
Menu wiring (`docs/parity-checklist.md`): 640 of 640 menu items live (100.0%). This counts dispatch, not behaviour.
|
||||
|
||||
| Id | Target | Status | Issue | Note |
|
||||
|---|---|---|---|---|
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ id = "TYPE-218-5"
|
||||
target = "OpenType UI: Character panel buttons, Numerals and Stylistic Sets submenus"
|
||||
status = "partial"
|
||||
issue = 218
|
||||
note = "Type > OpenType toggles (type_extra_cmds.rs:512). Character panel (and the Properties Character section) has Photoshop's eight OpenType buttons: Standard Ligatures, Contextual Alternates, Discretionary Ligatures, Swash, Stylistic Alternates, Titling Alternates, Ordinals, Fractions, pressed while the feature is on at the selection and dispatching the type.openType.* commands (type_tool.rs opentype_row; character_panel_opentype_buttons_toggle_and_show_the_feature, #3752). Still missing: the Numerals and Stylistic Sets submenus, and greying out features the font lacks"
|
||||
note = "Type > OpenType toggles (type_extra_cmds.rs). Character panel (and the Properties Character section) has Photoshop's eight OpenType buttons: Standard Ligatures, Contextual Alternates, Discretionary Ligatures, Swash, Stylistic Alternates, Titling Alternates, Ordinals, Fractions, pressed while the feature is on at the selection and dispatching the type.openType.* commands (type_tool.rs opentype_row; character_panel_opentype_buttons_toggle_and_show_the_feature, #3752). Type > OpenType > Numerals (Default, Lining, Oldstyle, Proportional, Tabular, and the four height×width combinations) landed 2026-11-03: each sets lnum/onum/pnum/tnum as a radio style on the selection or layer, round-trips .pcraft, and shows its checkmark from the style at the selection start. Still missing: the Stylistic Sets submenu, and greying out features the font lacks"
|
||||
|
||||
[[item]]
|
||||
id = "TYPE-218-6"
|
||||
|
||||
Reference in new issue
Block a user