Fix mixed-font editing, caret font changes and focused text commit

This commit is contained in:
Khawar Zamman Wani committed 2026-10-25 14:53:55 +05:30
1 parent b3f6e4e95b
commit 82d23db96b
7 files changed
+669 -29

No files matched your search

+3
View File
@@ -430,6 +430,9 @@ pub fn handle(app: &mut PhotocraftApp, ctx: &egui::Context) {
// pick an option rather than a tool (#1481). A command shortcut (⌘D, F7…) takes the keyboard
// off the bar first and runs, as with a native menu bar (#6573).
crate::menu_keys::leave_for_shortcut(ctx);
if app.ui.dialogs.is_empty() && app.discard.is_none() && crate::type_tool::commit_shortcut(app, ctx) {
return;
}
if crate::menu_nav::is_open(ctx) || crate::menu_keys::is_focused(ctx) || crate::widgets::dropdown_list_open(ctx) {
return;
}
+15
View File
@@ -1172,6 +1172,17 @@ pub struct BoxResize {
pub aff: photocraft_geom::Affine,
}
/// A font choice for subsequent typing, invalidated by navigation or a document edit.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TypeInsertionStyle {
pub document: u64,
pub layer: u64,
pub session: String,
pub revision: u64,
pub caret: usize,
pub style: photocraft_doc::text::CharStyle,
}
/// In-progress inline type editing (Type tool). Offsets are character indices.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TextEdit {
@@ -1380,6 +1391,9 @@ pub struct UiState {
/// Inline type editing session, if any.
#[serde(default)]
pub text_edit: Option<TextEdit>,
/// Font for subsequent typing at this caret, separate from existing character runs.
#[serde(default)]
pub type_insertion_style: Option<TypeInsertionStyle>,
/// Clock time in seconds when type cursor blink was last reset (e.g. on keypress/caret move).
#[serde(skip)]
pub caret_blink_time: f64,
@@ -1630,6 +1644,7 @@ impl Default for UiState {
recent_files: Vec::new(),
recent_fonts: Vec::new(),
text_edit: None,
type_insertion_style: None,
caret_blink_time: 0.0,
text_edit_return_tool: None,
type_transform: None,
@@ -0,0 +1,466 @@
//! Selected-range font acceptance, caret typing styles and focused global commit.
use crate::{PhotocraftApp, Services};
use egui::{Key, Modifiers, accesskit::Role, vec2};
use egui_kittest::{Harness, kittest::Queryable};
use photocraft_doc::{Document, LayerContent, LayerId};
use serde_json::{Value, json};
const FONTS: [&str; 2] = ["Inter", "JetBrains Mono"];
struct Probe {
app: PhotocraftApp,
character: bool,
}
impl eframe::App for Probe {
fn logic(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
crate::shortcuts::handle(&mut self.app, ctx);
crate::type_font_preview::follow_hover(&mut self.app, ctx);
}
fn ui(&mut self, ui: &mut egui::Ui, _: &mut eframe::Frame) {
if self.character {
ui.vertical(|ui| {
ui.set_width(340.0);
super::character_panel(&mut self.app, ui, false);
});
}
ui.horizontal(|ui| super::options_bar(&mut self.app, ui));
}
}
fn layer(doc: &Document, id: LayerId) -> &photocraft_doc::TextLayer {
let LayerContent::Text(t) = &doc.layer(id).unwrap().content else { panic!("text layer") };
t
}
fn styles(doc: &Document, id: LayerId) -> Value {
let t = layer(doc, id);
let runs = t.char_runs();
let mut at = 0;
let mut chars = Vec::new();
for r in runs {
let end = at + r.len;
for ch in t.text.get(at..end).unwrap().chars() {
chars.push(json!({"char": ch.to_string(), "font": r.style.font_family,
"face": r.style.postscript_name, "weight": r.style.weight, "italic": r.style.italic}));
}
at = end;
}
json!({"text": t.text, "summary": t.font_family, "chars": chars})
}
fn saved(h: &Harness<'_, Probe>, id: LayerId) -> Value {
styles(&h.state().app.session.active().unwrap().doc, id)
}
fn families(s: &Value) -> Vec<String> {
s["chars"].as_array().unwrap().iter().map(|c| c["font"].as_str().unwrap().to_owned()).collect()
}
fn fields(h: &Harness<'_, Probe>) -> Vec<Option<String>> {
h.query_all_by_role(Role::TextInput).map(|n| n.value()).collect()
}
fn select(h: &mut Harness<'_, Probe>, range: [usize; 2]) {
let e = h.state_mut().app.ui.text_edit.as_mut().unwrap();
e.anchor = range[0];
e.caret = range[1];
}
fn fixture(new: bool, pattern: usize, character: bool, content: &str) -> (Harness<'static, Probe>, LayerId) {
fixture_renderer(new, pattern, character, content, false, 1.0)
}
fn fixture_renderer(new: bool, pattern: usize, character: bool, content: &str, gpu: bool, scale: f32) -> (Harness<'static, Probe>, LayerId) {
let builder = Harness::builder().with_size(vec2(1100.0, 1000.0)).with_pixels_per_point(scale).with_max_steps(64);
let builder = if gpu { builder.wgpu() } else { builder };
let mut h = builder.build_eframe(move |cc| {
PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Services::default());
app.session.edit_prefs(|p| p.type_.font_preview = photocraft_engine::prefs::FontPreview::Off);
Probe { app, character }
});
let app = &mut h.state_mut().app;
app.run("file.new", json!({"width": 240, "height": 160})).unwrap();
app.sync_views();
app.ui.tool = crate::state::Tool::Type;
app.ui.tool_options.type_font = FONTS[pattern % 2].into();
app.ui.tool_options.type_size = 18.0;
super::pointer_up(app, [30.0, 70.0], [30.0, 70.0]);
super::insert(app, content);
let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer);
let key = app.ui.text_edit.as_ref().unwrap().session.clone();
// Build mixed styles through the same live edit session, preserving history/coalescing.
if pattern >= 2 {
app.run("type.setStyle", json!({"layer": id.0, "range": [2,4], "font": FONTS[1-pattern%2], "coalesce": key})).unwrap();
}
if !new {
super::commit(app);
super::edit_active(app).unwrap();
}
h.run_steps(3);
(h, id)
}
fn choose(h: &mut Harness<'_, Probe>, font: &str, accept: &str) {
h.query_all_by_role(Role::TextInput).next().unwrap().click();
h.run();
h.query_all_by_role(Role::TextInput).next().unwrap().type_text(font);
h.run();
match accept {
"enter" => h.key_press(Key::Enter),
"arrow-enter" => {
h.key_press(Key::ArrowDown);
h.run();
h.key_press(Key::Enter);
}
"click" => h.get_by_label(font).click(),
"hover" => h.get_by_label(font).hover(),
"query" => {}
"tab" => h.key_press(Key::Tab),
"escape" => h.key_press(Key::Escape),
_ => panic!("unknown acceptance"),
}
h.run();
}
fn commit(h: &mut Harness<'_, Probe>, method: &str) {
match method {
"checkmark" => {
let label = crate::i18n::fmt("Commit any current edits ({key})", &[("key", &crate::shortcuts::pretty("Cmd+Enter"))]);
h.get_by_role_and_label(Role::Button, &label).click();
h.run();
}
"outside" => {
super::pointer_down(&mut h.state_mut().app, 230.0, 150.0, Modifiers::NONE);
h.run();
}
"direct" => {
super::commit(&mut h.state_mut().app);
h.run();
}
"shortcut-focused" => {
h.key_press_modifiers(Modifiers::COMMAND, Key::Enter);
h.run();
}
"shortcut-unfocused" => {
h.ctx.memory_mut(|m| {
if let Some(id) = m.focused() {
m.surrender_focus(id);
}
});
h.key_press_modifiers(Modifiers::COMMAND, Key::Enter);
h.run();
}
"layer-switch" => {
h.state_mut().app.run("layer.new.layer", json!({})).unwrap();
super::end_if_left(&mut h.state_mut().app);
h.run();
}
"document-switch" => {
h.state_mut().app.run("file.new", json!({"width": 80, "height": 60})).unwrap();
super::end_if_left(&mut h.state_mut().app);
h.state_mut().app.session.set_active(0);
h.run();
}
_ => panic!("unknown commit"),
}
}
#[test]
fn selected_fonts_apply_and_survive_commit_across_controls_and_acceptance_methods() {
let mut cases = 0;
for new in [false, true] {
for pattern in 0..4 {
for character in [false, true] {
for range in [[0, 2], [2, 4], [4, 6], [0, 6], [4, 2], [1, 5]] {
for target in FONTS {
for accept in ["enter", "click", "arrow-enter"] {
for method in ["checkmark", "outside"] {
let label = (new, pattern, character, range, target, accept, method);
let (mut h, id) = fixture(new, pattern, character, "abcdef");
select(&mut h, range);
h.run();
let mut expected = families(&saved(&h, id));
for font in &mut expected[range[0].min(range[1])..range[0].max(range[1])] {
*font = target.into();
}
choose(&mut h, target, accept);
let applied = saved(&h, id);
assert_eq!(families(&applied), expected, "{label:?}");
assert_eq!(fields(&h)[0].as_deref(), Some(target), "selected font caption: {label:?}");
let pixels = layer(&h.state().app.session.active().unwrap().doc, id).cache.clone();
commit(&mut h, method);
assert!(h.state().app.ui.text_edit.is_none(), "{label:?}");
assert_eq!(saved(&h, id), applied, "{label:?}");
assert_eq!(layer(&h.state().app.session.active().unwrap().doc, id).cache, pixels, "{label:?}");
let uniform = expected.iter().all(|f| f == &expected[0]);
assert_eq!(
fields(&h)[0].clone().unwrap_or_default(),
if uniform { expected[0].clone() } else { String::new() },
"mixed caption after commit: {label:?}"
);
super::edit_active(&mut h.state_mut().app).unwrap();
select(&mut h, range);
h.run();
assert_eq!(fields(&h)[0].as_deref(), Some(target), "reselected caption: {label:?}");
cases += 1;
}
}
}
}
}
}
}
assert_eq!(cases, 1152);
}
#[test]
fn caret_font_choices_style_only_subsequent_typing_including_ime() {
for new in [false, true] {
for character in [false, true] {
for original in 0..2 {
for text in ["abcdef", "AéB👩‍💻", "ab\ncdé"] {
let n = text.chars().count();
for caret in [0, n / 2, n] {
for accept in ["enter", "click", "arrow-enter"] {
let (mut h, id) = fixture(new, original, character, text);
select(&mut h, [caret, caret]);
h.run();
let before = saved(&h, id);
let steps = h.state().app.session.active().unwrap().history.entries().len();
let font = FONTS[1 - original];
choose(&mut h, font, accept);
assert_eq!(saved(&h, id), before, "a font choice at a caret never restyles existing characters");
assert_eq!(h.state().app.session.active().unwrap().history.entries().len(), steps);
assert_eq!(fields(&h)[0].as_deref(), Some(font));
crate::type_font_preview::set(&mut h.state_mut().app, font.into());
assert!(crate::type_font_preview::display_doc(&mut h.state_mut().app, 0).is_none());
// Multiple preedit replacements and final commit keep the pending font.
super::ime_update(&mut h.state_mut().app, "é", false);
super::ime_update(&mut h.state_mut().app, "éX", true);
super::insert(&mut h.state_mut().app, "Z");
let mut expected = families(&before);
expected.splice(caret..caret, std::iter::repeat_n(font.to_string(), 3));
assert_eq!(families(&saved(&h, id)), expected);
let typed = saved(&h, id);
commit(&mut h, "checkmark");
assert_eq!(saved(&h, id), typed);
assert!(h.state().app.ui.type_insertion_style.is_none());
}
}
}
}
}
}
}
#[test]
fn global_commit_accepts_pending_font_queries_and_leaves_no_focused_field() {
for new in [false, true] {
for character in [false, true] {
for accept in ["enter", "click", "arrow-enter", "query", "hover", "tab", "escape"] {
for method in ["shortcut-focused", "shortcut-unfocused", "layer-switch", "document-switch"] {
let (mut h, id) = fixture(new, 0, character, "abcdef");
select(&mut h, [2, 4]);
h.run();
choose(&mut h, FONTS[1], accept);
commit(&mut h, method);
assert!(h.state().app.ui.text_edit.is_none(), "{new}/{character}/{accept}/{method}");
let mut expected = vec![FONTS[0].to_string(); 6];
if matches!(accept, "enter" | "click" | "arrow-enter") || (method == "shortcut-focused" && matches!(accept, "query" | "hover")) {
expected[2..4].fill(FONTS[1].into());
}
assert_eq!(families(&saved(&h, id)), expected, "{new}/{character}/{accept}/{method}");
}
}
}
}
}
#[test]
fn caret_style_is_discarded_by_navigation_cancel_undo_and_document_switch() {
for action in ["navigation", "cancel", "undo", "document-switch"] {
let (mut h, id) = fixture(false, 0, false, "abcdef");
select(&mut h, [3, 3]);
h.run();
choose(&mut h, FONTS[1], "enter");
match action {
"navigation" => {
h.ctx.memory_mut(|m| {
if let Some(id) = m.focused() {
m.surrender_focus(id);
}
});
h.key_press(Key::ArrowLeft);
h.run();
h.key_press(Key::ArrowRight);
h.run();
super::insert(&mut h.state_mut().app, "Z");
assert!(families(&saved(&h, id)).iter().all(|f| f == FONTS[0]));
}
"cancel" => {
super::cancel(&mut h.state_mut().app);
assert!(h.state().app.ui.type_insertion_style.is_none());
}
"undo" => {
h.state_mut().app.run("type.setStyle", json!({"layer":id.0,"range":[0,1],"font":FONTS[1]})).unwrap();
assert!(h.state_mut().app.session.undo());
assert!(super::insertion_style::pending(&h.state().app).is_none());
}
_ => {
commit(&mut h, "document-switch");
assert!(h.state().app.ui.type_insertion_style.is_none());
}
}
}
}
#[test]
fn returning_focus_to_the_same_canvas_caret_keeps_the_chosen_typing_font() {
let (mut h, id) = fixture(false, 0, false, "abcdef");
select(&mut h, [6, 6]);
h.run();
choose(&mut h, FONTS[1], "enter");
let (layout, aff, text) = super::layout(&mut h.state_mut().app, id).unwrap();
let (x, top, bottom) = layout.caret(text.len());
let p = aff.apply(photocraft_geom::Point::new(f64::from(x) - 0.1, f64::from((top + bottom) * 0.5)));
assert!(super::pointer_down(&mut h.state_mut().app, p.x, p.y, Modifiers::NONE));
super::pointer_up(&mut h.state_mut().app, [p.x, p.y], [p.x, p.y]);
assert_eq!(h.state().app.ui.text_edit.as_ref().unwrap().caret, 6);
assert!(super::insertion_style::pending(&h.state().app).is_some());
h.ctx.memory_mut(|m| {
if let Some(id) = m.focused() {
m.surrender_focus(id);
}
});
h.event(egui::Event::Text("XYZ".into()));
h.run();
assert_eq!(families(&saved(&h, id)), [FONTS[0], FONTS[0], FONTS[0], FONTS[0], FONTS[0], FONTS[0], FONTS[1], FONTS[1], FONTS[1]]);
}
#[test]
fn commit_does_not_accept_an_invalid_font_or_interrupt_ime() {
for (character, query) in [(false, "no such font zzz"), (true, "no such font zzz"), (false, " "), (true, " ")] {
let (mut h, id) = fixture(false, 0, character, "abcdef");
select(&mut h, [2, 4]);
h.run();
choose(&mut h, query, "query");
commit(&mut h, "shortcut-focused");
assert!(h.state().app.ui.text_edit.is_none());
assert_eq!(families(&saved(&h, id)), vec![FONTS[0]; 6]);
super::edit_active(&mut h.state_mut().app).unwrap();
super::ime_update(&mut h.state_mut().app, "é", false);
h.key_press_modifiers(Modifiers::COMMAND, Key::Enter);
h.run();
assert!(h.state().app.ui.text_edit.is_some(), "composition owns its confirmation");
}
}
#[test]
fn font_field_composition_keeps_confirmation_then_releases_global_commit() {
for disabled in [false, true] {
let (mut h, id) = fixture(false, 0, false, "abcdef");
select(&mut h, [2, 4]);
h.run();
h.query_all_by_role(Role::TextInput).next().unwrap().click();
h.run();
h.event(egui::Event::Ime(egui::ImeEvent::Preedit { text: FONTS[1].into(), active_range_chars: None }));
h.run();
commit(&mut h, "shortcut-focused");
assert!(h.state().app.ui.text_edit.is_some());
assert_eq!(families(&saved(&h, id)), vec![FONTS[0]; 6]);
if disabled {
h.event(egui::Event::Ime(egui::ImeEvent::Disabled));
h.run();
h.key_press_modifiers(Modifiers::COMMAND, Key::A);
h.event(egui::Event::Text(FONTS[1].into()));
h.run();
} else {
h.event(egui::Event::Ime(egui::ImeEvent::Commit(FONTS[1].into())));
h.run();
}
commit(&mut h, "shortcut-focused");
assert!(h.state().app.ui.text_edit.is_none());
assert_eq!(families(&saved(&h, id)), [FONTS[0], FONTS[0], FONTS[1], FONTS[1], FONTS[0], FONTS[0]]);
}
}
#[test]
fn caret_font_and_face_persist_across_more_font_choices_and_paste() {
let (mut h, id) = fixture(false, 0, false, "abcdef");
select(&mut h, [3, 3]);
h.run();
choose(&mut h, FONTS[1], "enter");
let ctx = h.ctx.clone();
super::apply(&mut h.state_mut().app, &ctx, json!({"fontStyle":"Bold"}));
choose(&mut h, FONTS[0], "enter");
h.ctx.memory_mut(|m| {
if let Some(id) = m.focused() {
m.surrender_focus(id);
}
});
h.event(egui::Event::Paste("éX".into()));
h.run();
let t = saved(&h, id);
for (i, c) in t["chars"].as_array().unwrap().iter().enumerate() {
assert_eq!(c["font"], FONTS[0]);
assert_eq!(c["weight"], if (3..5).contains(&i) { 700 } else { 400 });
}
let applied = saved(&h, id);
commit(&mut h, "shortcut-focused");
assert_eq!(saved(&h, id), applied);
for name in ["probe.pcraft", "probe.psd"] {
let doc = h.state().app.session.active().unwrap().doc.clone();
let out = photocraft_io::export(&doc, name, &Default::default()).unwrap();
let back = photocraft_io::import(name, &out.bytes).unwrap().document;
let imported_id = back.walk().into_iter().find_map(|(_, _, l)| matches!(l.content, LayerContent::Text(_)).then_some(l.id)).unwrap();
assert_eq!(families(&styles(&back, imported_id)), families(&applied));
}
assert!(h.state_mut().app.session.undo());
assert_eq!(saved(&h, id)["text"], "abcdef");
assert!(h.state_mut().app.session.redo());
assert_eq!(saved(&h, id), applied);
}
#[test]
fn an_existing_empty_layer_keeps_its_font_when_committed() {
for character in [false, true] {
let (mut h, id) = fixture(false, 0, character, "abcdef");
h.state_mut().app.run("type.edit", json!({"layer":id.0,"text":""})).unwrap();
select(&mut h, [0, 0]);
h.run();
choose(&mut h, FONTS[1], "enter");
commit(&mut h, "checkmark");
assert_eq!(saved(&h, id)["summary"], FONTS[1]);
super::edit_active(&mut h.state_mut().app).unwrap();
super::insert(&mut h.state_mut().app, "X");
assert_eq!(families(&saved(&h, id)), [FONTS[1]]);
}
}
#[test]
fn font_commit_gpu_snapshots() {
let Some(path) = std::env::var_os("FONT_COMMIT_VISUALS").map(std::path::PathBuf::from) else { return };
let _gpu = photocraft_testkit::gpu_lock();
std::fs::create_dir_all(&path).unwrap();
for character in [false, true] {
for scale in [1.0, 2.0] {
let (mut h, _) = fixture_renderer(false, 0, character, "abcdef", true, scale);
select(&mut h, [2, 4]);
h.run();
choose(&mut h, FONTS[1], "enter");
h.render().unwrap().save(path.join(format!("selected-{character}-{scale}x.png"))).unwrap();
commit(&mut h, "checkmark");
h.render().unwrap().save(path.join(format!("committed-mixed-{character}-{scale}x.png"))).unwrap();
super::edit_active(&mut h.state_mut().app).unwrap();
select(&mut h, [2, 4]);
h.run();
h.render().unwrap().save(path.join(format!("reselected-{character}-{scale}x.png"))).unwrap();
select(&mut h, [6, 6]);
h.run();
choose(&mut h, FONTS[1], "enter");
h.render().unwrap().save(path.join(format!("caret-{character}-{scale}x.png"))).unwrap();
}
}
}
+5
View File
@@ -109,6 +109,11 @@ pub(crate) fn display_doc(app: &mut PhotocraftApp, idx: usize) -> Option<(Arc<Do
}
pub(crate) fn set(app: &mut PhotocraftApp, family: String) {
// A caret's font formats subsequent typing, not the existing layer's pixels.
if app.ui.text_edit.as_ref().is_some_and(|ed| ed.caret == ed.anchor) {
clear(app);
return;
}
let Some((layer, range)) = crate::type_tool::target(app) else {
clear(app);
return;
@@ -0,0 +1,67 @@
//! A caret's pending font is view state; inserted runs still travel through `type.edit`.
use super::*;
use crate::state::TypeInsertionStyle;
pub(super) fn pending(app: &PhotocraftApp) -> Option<&TypeInsertionStyle> {
let ed = app.ui.text_edit.as_ref()?;
let p = app.ui.type_insertion_style.as_ref()?;
let st = app.session.active()?;
(st.doc.id.0 == p.document && ed.layer == p.layer && ed.session == p.session && ed.caret == ed.anchor && ed.caret == p.caret && st.revision == p.revision)
.then_some(p)
}
pub(super) fn shown(app: &PhotocraftApp, c: &mut photocraft_doc::text::CharStyle) {
if let Some(p) = pending(app) {
c.clone_from(&p.style);
}
}
pub(super) fn set_font(app: &mut PhotocraftApp, props: &serde_json::Value) -> bool {
if app.ui.text_edit.as_ref().is_none_or(|ed| ed.caret != ed.anchor) || (props.get("font").is_none() && props.get("fontStyle").is_none()) {
return false;
}
crate::type_transform::finish(app);
let Some(ed) = app.ui.text_edit.as_ref() else { return false };
// Empty layers already have a persistent typing run; there are no earlier letters to protect.
if app.session.active().and_then(|st| text_layer(&st.doc, LayerId(ed.layer))).is_some_and(|t| t.text.is_empty()) {
return false;
}
let Some((mut style, _)) = styles_at(app) else { return false };
let Some(st) = app.session.active() else { return false };
photocraft_engine::type_cmds::apply_char_props(&mut style, props);
app.ui.type_insertion_style =
Some(TypeInsertionStyle { document: st.doc.id.0, layer: ed.layer, session: ed.session.clone(), revision: st.revision, caret: ed.caret, style });
true
}
/// Replace and style the inserted characters atomically, including paste and IME preedit.
pub(super) fn replace(app: &mut PhotocraftApp, start: usize, end: usize, text: &str) -> bool {
let Some(ed) = app.ui.text_edit.clone() else { return false };
let pending = pending(app).cloned();
let caret = start.saturating_add(text.chars().count());
let mut params = json!({"layer": ed.layer, "replace": {"start": start, "end": end, "text": text}, "coalesce": ed.session});
if let Some(p) = &pending
&& !text.is_empty()
{
let mut run = json!({"start": start, "end": caret, "font": p.style.font_family, "weight": p.style.weight, "italic": p.style.italic});
if let Some(face) = &p.style.postscript_name {
run["postscriptName"] = json!(face);
}
params["runs"] = json!([run]);
}
if let Err(e) = app.run("type.edit", params) {
app.ui.status = e;
app.ui.status_error = true;
return false;
}
if let Some(ed) = app.ui.text_edit.as_mut() {
ed.caret = caret;
ed.anchor = caret;
}
app.ui.type_insertion_style = pending.and_then(|mut p| {
p.caret = caret;
p.revision = app.session.active()?.revision;
Some(p)
});
true
}
+109 -27
View File
@@ -17,6 +17,9 @@ use crate::PhotocraftApp;
use crate::canvas::ViewXform;
use crate::state::{BoxResize, TextEdit};
#[path = "type_insertion_style.rs"]
mod insertion_style;
pub const PLACEHOLDER: &str = "Lorem Ipsum";
fn text_layer(doc: &Document, id: LayerId) -> Option<&TextLayer> {
@@ -114,6 +117,7 @@ fn begin_edit(app: &mut PhotocraftApp, id: LayerId, key: &str) -> Result<(), Str
/// Edit the active type layer from its thumbnail, selecting all text like Photoshop. Reuse the
/// current session when already editing it, so Cancel and undo still cover the whole edit.
pub fn edit_active(app: &mut PhotocraftApp) -> Result<(), String> {
app.ui.type_insertion_style = None;
let st = app.session.active().ok_or("no document open")?;
let id = st.active_layer.ok_or("no active layer")?;
let n = text_layer(&st.doc, id).ok_or("active layer is not a type layer")?.text.chars().count();
@@ -311,6 +315,7 @@ pub fn pointer_down(app: &mut PhotocraftApp, x: f64, y: f64, mods: egui::Modifie
if let Some(ed) = app.ui.text_edit.clone() {
let id = LayerId(ed.layer);
if let Some(i) = box_handle_at(app, id, x, y) {
app.ui.type_insertion_style = None;
// Snapshot the box and transform now: every move recomputes from them, so ⌥ held
// or released mid-drag mirrors about the centre the drag started with.
let snap = box_shape(app, id).zip(layout(app, id)).map(|((bx, by, w, h), (_, aff, _))| BoxResize { handle: i, shape: [bx, by, w, h], aff });
@@ -323,6 +328,9 @@ pub fn pointer_down(app: &mut PhotocraftApp, x: f64, y: f64, mods: egui::Modifie
// (left of a line's start, below the last line); only a click outside it commits.
if hit_layer(app, x, y) == Some(id) || inside_box(app, id, x, y) {
let off = hit_offset(app, id, x, y);
if off != ed.caret || (!mods.shift && off != ed.anchor) {
app.ui.type_insertion_style = None;
}
if let Some(e) = app.ui.text_edit.as_mut() {
e.caret = off;
if !mods.shift {
@@ -336,6 +344,7 @@ pub fn pointer_down(app: &mut PhotocraftApp, x: f64, y: f64, mods: egui::Modifie
commit_with(app, mods);
return true; // Photoshop: a click outside commits without starting new text
}
app.ui.type_insertion_style = None;
// The Type Mask tools always start new text: existing type layers are just pixels to them;
// so does a ⇧-click with the Type tool, as in Photoshop, to start new text over old.
if app.ui.tool.is_type_mask() || mods.shift {
@@ -374,6 +383,9 @@ pub fn pointer_move(app: &mut PhotocraftApp, x: f64, y: f64, mods: egui::Modifie
}
if ed.dragging {
let off = hit_offset(app, LayerId(ed.layer), x, y);
if off != ed.caret {
app.ui.type_insertion_style = None;
}
if let Some(e) = app.ui.text_edit.as_mut() {
e.caret = off;
}
@@ -617,12 +629,7 @@ fn insert(app: &mut PhotocraftApp, s: &str) {
return;
}
crate::type_transform::finish(app);
if app.run("type.edit", json!({"layer": ed.layer, "replace": {"start": a, "end": b, "text": s}, "coalesce": ed.session})).is_ok()
&& let Some(e) = app.ui.text_edit.as_mut()
{
e.caret = a + s.chars().count();
e.anchor = e.caret;
}
insertion_style::replace(app, a, b, &s);
}
/// Typed text (not a paste): with Preferences ▸ Type ▸ Use Smart Quotes, straight quotes become
@@ -839,11 +846,9 @@ fn ime_update(app: &mut PhotocraftApp, s: &str, commit: bool) {
}
let len = s.chars().count();
crate::type_transform::finish(app);
if app.run("type.edit", json!({"layer": ed.layer, "replace": {"start": start, "end": end, "text": s}, "coalesce": ed.session})).is_ok()
if insertion_style::replace(app, start, end, &s)
&& let Some(e) = app.ui.text_edit.as_mut()
{
e.caret = start + len;
e.anchor = e.caret;
e.preedit = if commit || len == 0 { None } else { Some((start, len)) };
}
}
@@ -1018,6 +1023,9 @@ pub fn handle_keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool {
let n = text.chars().count();
let set = |app: &mut PhotocraftApp, caret: usize, extend: bool| {
if let Some(e) = app.ui.text_edit.as_mut() {
if e.caret != caret.min(n) || (!extend && e.anchor != caret.min(n)) {
app.ui.type_insertion_style = None;
}
e.caret = caret.min(n);
if !extend {
e.anchor = e.caret;
@@ -1123,7 +1131,8 @@ pub fn handle_keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool {
let to = line_edge(app, id, ed.caret, *key == Key::End);
set(app, to, m.shift);
}
Key::Enter if m.command => commit_with(app, *m),
Key::Enter if m.command && ed.preedit.is_none() => commit_with(app, *m),
Key::Enter if m.command => {} // IME owns confirmation until preedit ends.
Key::Enter => insert(app, "\n"),
// Photoshop types a tab character; layout advances it to the next tab stop.
Key::Tab if !m.command && !m.alt && !m.shift => {
@@ -1140,6 +1149,7 @@ pub fn handle_keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool {
Key::Escape if app.session.prefs().type_.use_esc_to_commit => commit(app),
Key::Escape => cancel(app),
Key::A if m.command => {
app.ui.type_insertion_style = None;
if let Some(e) = app.ui.text_edit.as_mut() {
e.anchor = 0;
e.caret = n;
@@ -1183,10 +1193,58 @@ pub fn commit(app: &mut PhotocraftApp) {
commit_with(app, egui::Modifiers::NONE);
}
/// The document's commit shortcut also works while a Type field owns keyboard input.
/// Resolve a pending font query before ending the edit; composition still owns its keys.
pub(crate) fn commit_shortcut(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool {
let Some(ed) = app.ui.text_edit.as_ref() else { return false };
let composing = ed.preedit.is_some();
let mods = ctx.input(|i| {
i.events.iter().find_map(|e| match e {
egui::Event::Key { key: egui::Key::Enter, pressed: true, modifiers, .. } if modifiers.command => Some(*modifiers),
_ => None,
})
});
let Some(mods) = mods else { return false };
let focused = ctx.memory(|m| m.focused());
let font_edit = focused.and_then(|id| ctx.data(|d| d.get_temp::<FontFieldEdit>(id.with("edit"))));
ctx.input_mut(|i| i.events.retain(|e| !matches!(e, egui::Event::Key { key: egui::Key::Enter, modifiers, .. } if modifiers.command)));
if composing || font_edit.as_ref().is_some_and(|e| e.composing) || ctx.input(|i| i.events.iter().any(|e| matches!(e, egui::Event::Ime(_)))) {
// Suppress the document/path shortcut, but leave IME events for their focused editor.
return false;
}
end_if_left(app);
if app.ui.text_edit.is_none() {
return true;
}
if let Some(edit) = font_edit.filter(|e| !e.accepted && !e.text.trim().is_empty() && !e.query.is_empty()) {
let families = families();
let labels: Option<Arc<HashMap<String, String>>> = ctx.data(|d| d.get_temp(font_labels_id()));
let (rows, _) = font_menu_rows(&families, labels.as_deref(), &edit.query, &edit.recents);
let exact = edit.text.to_lowercase();
let family =
rows.iter().find(|(f, shown)| f.to_lowercase() == exact || shown.to_lowercase() == exact).or_else(|| rows.first()).map(|(f, _)| (*f).clone());
if let Some(family) = family {
photocraft_text::served::request(&family);
app.note_recent_font(&family);
app.ui.tool_options.type_font = family.clone();
apply(app, ctx, json!({"font": family}));
}
}
if let Some(field) = focused {
ctx.memory_mut(|m| m.surrender_focus(field));
ctx.data_mut(|d| d.remove::<FontFieldEdit>(field.with("edit")));
}
egui::Popup::close_all(ctx);
crate::type_font_preview::clear(app);
commit_with(app, mods);
true
}
/// [`commit`] with the modifiers held while committing: a Type Mask adds its glyphs to the
/// selection with ⇧, subtracts them with ⌥ and intersects with ⇧⌥ (Photoshop); with none it
/// replaces the selection.
pub fn commit_with(app: &mut PhotocraftApp, mods: egui::Modifiers) {
app.ui.type_insertion_style = None;
let current = app.session.active_index();
let Some(home) = app.ui.text_edit.as_ref().map(|ed| edit_home(app, ed)) else {
return commit_here(app, mods);
@@ -1828,7 +1886,7 @@ pub(crate) fn family_picker_in(
for event in &i.events {
match event {
egui::Event::Ime(egui::ImeEvent::Preedit { text, .. }) => edit.composing = !text.is_empty(),
egui::Event::Ime(egui::ImeEvent::Commit(_)) => edit.composing = false,
egui::Event::Ime(egui::ImeEvent::Commit(_) | egui::ImeEvent::Disabled) => edit.composing = false,
_ => {}
}
}
@@ -1926,7 +1984,9 @@ pub(crate) fn family_picker_in(
.or(selected)
.or_else(|| (!rows.is_empty()).then_some(0));
if let Some((f, _)) = accept.and_then(|i| rows.get(i)) {
changed |= **f != *current;
// Acceptance is an application to the selected characters, even when a
// mixed selection's representative already has this family (as row clicks do).
changed = true;
current.clone_from(f);
photocraft_text::served::request(f);
picked = true;
@@ -2248,6 +2308,10 @@ fn apply_defaults(app: &mut PhotocraftApp, props: &serde_json::Value) {
/// Apply only the supplied properties to the text-edit scope or selected type layers; without
/// a type target, prepare the defaults for the next layer instead.
fn apply(app: &mut PhotocraftApp, ctx: &egui::Context, props: serde_json::Value) {
if insertion_style::set_font(app, &props) {
return;
}
app.ui.type_insertion_style = None;
let Some(mut p) = formatting_params(app) else {
apply_defaults(app, &props);
return;
@@ -2299,15 +2363,8 @@ pub fn foreground_changed(app: &mut PhotocraftApp) {
/// Photoshop's Type options bar.
pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = crate::theme::Tokens::get(ui.ctx());
// Show the target layer's (first-run) style, else the tool defaults.
let shown = target(app).and_then(|(id, _)| {
let st = app.session.active()?;
let tl = text_layer(&st.doc, LayerId(id))?;
let run = tl.char_runs().into_iter().next().map(|r| r.style);
// The size at the selection (else the first run), as the layer shows it (#124).
let size = styles_at(app).map_or(tl.size_pt, |(c, _)| c.size_pt) * shown_scale(app);
Some((tl.font_family.clone(), run.as_ref().map(selected_style).unwrap_or_default(), size, styles_at(app).map_or(tl.color, |(c, _)| c.color)))
});
// Both Type controls describe the selected characters, or the caret's typing style.
let shown = styles_at(app).map(|(c, _)| (shown_family(app, &c), selected_style(&c), c.size_pt * shown_scale(app), c.color));
let o = app.ui.tool_options.clone();
let (mut fam, mut style, size) = match &shown {
Some((f, s, z, _)) => (f.clone(), if s.is_empty() { "Regular".into() } else { s.clone() }, *z),
@@ -2333,7 +2390,8 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
app.ui.tool_options.type_style = style.clone();
apply(app, ui.ctx(), json!({"font": fam}));
}
let opts: Vec<(String, String)> = styles(&fam).into_iter().map(|s| (s.clone(), style_label(&s))).collect();
let style_family = if fam.is_empty() { styles_at(app).map(|(c, _)| c.font_family).unwrap_or_default() } else { fam.clone() };
let opts: Vec<(String, String)> = styles(&style_family).into_iter().map(|s| (s.clone(), style_label(&s))).collect();
let opts_ref: Vec<(String, &str)> = opts.iter().map(|(a, b)| (a.clone(), b.as_str())).collect();
if crate::widgets::dropdown(ui, "type-style", &mut style, &opts_ref, 110.0) {
app.ui.tool_options.type_style = style.clone();
@@ -2437,12 +2495,29 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
}
/// Character and paragraph style at the target (selection start, else the layer's first run).
/// A blank family represents mixed fonts, rather than falsely reporting the first one after
/// commit. At a caret, the current/pending insertion font is the relevant single style.
fn shown_family(app: &PhotocraftApp, c: &photocraft_doc::text::CharStyle) -> String {
let same = |s: &photocraft_doc::text::CharStyle| s.font_family == c.font_family;
let Some(st) = app.session.active() else { return c.font_family.clone() };
let uniform = if let Some(ed) = &app.ui.text_edit {
if ed.caret == ed.anchor {
true
} else {
text_layer(&st.doc, LayerId(ed.layer)).is_none_or(|t| selected_styles(t, ed.anchor, ed.caret).iter().all(same))
}
} else {
st.selected_layers().into_iter().filter_map(|id| text_layer(&st.doc, id)).all(|t| t.char_runs().iter().all(|r| same(&r.style)))
};
if uniform { c.font_family.clone() } else { String::new() }
}
/// Character and paragraph style at the selection, caret, or first run of selected layers.
pub(crate) fn styles_at(app: &PhotocraftApp) -> Option<(photocraft_doc::text::CharStyle, photocraft_doc::text::ParagraphStyle)> {
let (layer, range) = target(app)?;
let st = app.session.active()?;
let t = text_layer(&st.doc, LayerId(layer))?;
let at = range.map_or(0, |r| byte_of(&t.text, r[0]));
let at = range.map_or_else(|| app.ui.text_edit.as_ref().map_or(0, |ed| byte_of(&t.text, ed.caret.saturating_sub(1))), |r| byte_of(&t.text, r[0]));
let pick = |lens: Vec<usize>| -> usize {
let mut acc = 0;
for (i, len) in lens.iter().enumerate() {
@@ -2455,7 +2530,8 @@ pub(crate) fn styles_at(app: &PhotocraftApp) -> Option<(photocraft_doc::text::Ch
};
let runs = t.char_runs();
let paras = t.paragraph_runs();
let c = runs.get(pick(runs.iter().map(|r| r.len).collect())).map(|r| r.style.clone())?;
let mut c = runs.get(pick(runs.iter().map(|r| r.len).collect())).map(|r| r.style.clone())?;
insertion_style::shown(app, &mut c);
let p = paras.get(pick(paras.iter().map(|r| r.len).collect())).map(|r| r.style.clone()).unwrap_or_default();
Some((c, p))
}
@@ -2818,7 +2894,7 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, pa
if character && section(ui, "character", tl!("Character")) {
let full = ui.available_width();
let w = field_width(full, 2, LABEL_W);
let mut fam = c.font_family.clone();
let mut fam = shown_family(app, &c);
let mut ready = true;
row(ui, &mut |ui| {
ready = fonts_ready(ui, full);
@@ -2833,7 +2909,8 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, pa
return;
}
let mut style = selected_style(&c);
let opts: Vec<(String, String)> = styles(&fam).into_iter().map(|s| (s.clone(), style_label(&s))).collect();
let opts: Vec<(String, String)> =
styles(if fam.is_empty() { &c.font_family } else { &fam }).into_iter().map(|s| (s.clone(), style_label(&s))).collect();
let opts_ref: Vec<(String, &str)> = opts.iter().map(|(a, b)| (a.clone(), b.as_str())).collect();
if crate::widgets::dropdown(ui, "props-type-style", &mut style, &opts_ref, full) {
apply(app, ui.ctx(), json!({"fontStyle": style}));
@@ -3111,6 +3188,7 @@ fn type_options(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
/// Cancel the editing session: undo it back to where it started (removes a new layer).
pub fn cancel(app: &mut PhotocraftApp) {
app.ui.type_insertion_style = None;
crate::type_transform::reset(app);
let Some(ed) = app.ui.text_edit.take() else { return };
if let Some(tool) = app.ui.text_edit_return_tool.take()
@@ -3137,6 +3215,10 @@ mod canvas_tests;
#[path = "type_font_picker_tests.rs"]
mod font_picker_tests;
#[cfg(test)]
#[path = "type_font_commit_tests.rs"]
mod font_commit_tests;
#[cfg(test)]
mod tests {
use super::*;
+4 -2
View File
@@ -1,6 +1,6 @@
# UI parity: tools, handles, modifiers and feel
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-25 · **Change:** minor (direct font-name editing in shared Type controls with a compact no-match message, #9338; ⌥ + an adjustment's shortcut reopens it at its last settings, ⌥⌘L / ⌥⌘M, #8900; Crop default mode: moving the image under the box snaps the frame's edges and centre, #8580; View › Extras hides the Move transform controls, #6699; adjustment clipping stays visible in compact Properties, #5231; Color panel modes from its panel menu, the same in every theme, UI-217-17, #6000; a picked colour recolours the selected type and shapes; Hand tool ⌘ / ⌥ are Zoom In / Zoom Out while held, #6434; the wheel steps value fields, #5473; a dragged guide shows its X or Y beside the pointer, #7680; Type options bar "T" icon scrubs the font size, #6437; Move tool: dragged selected pixels take their own outline as the selection, #7538; artboard backgrounds remain below child Free Transform previews; ⌫/Delete removes the selected smart filter, #4751; Object Finder foreground/background discrimination (#6548); rounded triangle, polygon and star corners; shape Fill/Stroke popovers accept hex RGB values, #6176; a guide let go over either ruler is removed, #6286; Crop rows corrected: saved crop presets and Delete Cropped Pixels off are done, #6562; marching ants in device pixels, #7489; Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests) · **Target:** Adobe Photoshop 2026
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-25 · **Change:** minor (selection-aware font controls, pending caret fonts and focused commit, plus direct font-name editing with a compact no-match message, #9338; ⌥ + an adjustment's shortcut reopens it at its last settings, ⌥⌘L / ⌥⌘M, #8900; Crop default mode: moving the image under the box snaps the frame's edges and centre, #8580; View › Extras hides the Move transform controls, #6699; adjustment clipping stays visible in compact Properties, #5231; Color panel modes from its panel menu, the same in every theme, UI-217-17, #6000; a picked colour recolours the selected type and shapes; Hand tool ⌘ / ⌥ are Zoom In / Zoom Out while held, #6434; the wheel steps value fields, #5473; a dragged guide shows its X or Y beside the pointer, #7680; Type options bar "T" icon scrubs the font size, #6437; Move tool: dragged selected pixels take their own outline as the selection, #7538; artboard backgrounds remain below child Free Transform previews; ⌫/Delete removes the selected smart filter, #4751; Object Finder foreground/background discrimination (#6548); rounded triangle, polygon and star corners; shape Fill/Stroke popovers accept hex RGB values, #6176; a guide let go over either ruler is removed, #6286; Crop rows corrected: saved crop presets and Delete Cropped Pixels off are done, #6562; marching ants in device pixels, #7489; Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests) · **Target:** Adobe Photoshop 2026
How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, the
handles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,
@@ -171,7 +171,7 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme
| Geometry precision | partial | `geom::Point` f64, paths f64; paint internals mostly f32 |
| Numeric fields: arithmetic, scrubby labels | partial | units in expressions and double-click reset missing (UI-217-13) |
| Wheel steps a value field, ⇧ ×10: clicked into, wherever the pointer is; not clicked, a gesture that starts over it | partial | `field_wheel.rs` (#5473, #4061). Photoshop: a field takes the wheel once clicked into (shortcut guides, user reports); whether the pointer must stay over it is unconfirmed. Stepping on hover alone is Photopea's, kept deliberately |
| Font-name field: click selects the full name; typing searches in place | done | `type_tool.rs` `family_picker_in`, `type_font_picker_tests.rs` (#9338): one editable name above the list; unmatched queries show a compact message; Enter or a row accepts; Escape/outside click discards pending text; existing navigation and previews retained |
| Font-name field: click selects the full name; typing searches in place | done | `type_tool.rs` `family_picker_in`, `type_font_picker_tests.rs` (#9338): one editable name above the list; unmatched queries show a compact message; Enter or a row applies to the selected characters even when the family matches their representative; both controls show the selected span and leave mixed families blank; caret font choices affect subsequent typing; Ctrl/Cmd+Enter accepts a valid pending font query and commits from a focused field; Escape/outside click discards pending text; existing navigation and previews retained |
| Type options bar: drag the "T" icon to change the font size | done | `type_tool.rs` `options_bar`: the icon scrubs the size field like the Character panel's icons (Shift x10, Alt fine), at layer or selection scope, one history step per drag, within 1–1296 pt (#6437) |
## Navigation
@@ -302,3 +302,5 @@ Paragraph; the rest open as in-app floating windows.
| 2026-10-15 | minor | Color panel: Photoshop's panel-menu modes, colour ramp and copy commands; the theme no longer picks the panel's layout (UI-217-17 done, #2569, #6000) |
| 2026-10-23 | minor | ⌥ + an adjustment's shortcut (⌥⌘L Levels, ⌥⌘M Curves) opens its dialog at the settings of its last OK, as in Photoshop (#8900); no percentage changed |
| 2026-10-25 | minor | Shared font-family fields support direct name editing and search, with full-name selection on entry, explicit acceptance and cancellation, plus a compact no-match result (#9338); no percentage changed |
| 2026-10-25 | minor | RC2 follow-up: selection-aware font family/style display, explicit keyboard application to mixed selections, pending caret fonts for typing/paste/IME, and Ctrl/Cmd+Enter from focused Type fields (`type_font_commit_tests.rs`); no percentage changed |