UI: Arabic, Hebrew, Indic and Thai names can be typed and are drawn (#394)
Cause: two things kept Arabic out of a layer name on Windows. - Windows switches the keyboard layout with Alt+Shift. Releasing Shift before Alt left Alt held alone, and the in-window menu bar (#279) counted the release as an Alt tap: it took the keyboard focus, the rename field closed, and the letters typed next were swallowed by the menu bar. The Project panel's rename field lost them the same way. - The UI fonts are Inter plus the CJK system fallbacks, so Arabic, Hebrew, Indic and Thai names that did arrive (pasted, or from a project) showed as missing-glyph boxes. Fix: - An Alt tap only counts when Alt went down with no other modifier held, so Alt+Shift in either release order is no tap; a plain Alt tap still focuses the menu bar. - The UI registers installed system faces for Arabic, Hebrew, Devanagari, Bengali, Gurmukhi, Gujarati, Tamil, Telugu, Kannada, Malayalam and Thai after the CJK ones, the same way (native only; the web build has no system fonts). A face covering several scripts is registered once (Segoe UI: Arabic and Hebrew; Nirmala UI: every Indic script). - The text engine's fallback tries each script's plain platform families (Segoe UI, Nirmala UI, Leelawadee UI, Geeza Pro, Kohinoor, Noto…) before any covering face, so neither the UI nor a text layer gets a calligraphic face that merely sorts first. - The Timeline's rename field registers `timeline.layer.<id>.nameEdit`. egui 0.36 shapes each run of one face, so Arabic letters join and a word reads right to left; it has no bidirectional layout, so the words of a multi-word Arabic name (and mixed Arabic/Latin) still follow each other left to right. Tests: ui_inline_edit a_layout_switch_keeps_the_name_field_and_arabic_ names_are_kept (Alt+Shift both ways in the layer rename, Arabic typed and stored; Hebrew/Devanagari/Thai in the Project panel; a plain Alt tap still focuses File; failed before: the field closed), theme installed_script_fallbacks_draw_arabic_hebrew_indic_and_thai_names (failed before: replacement glyph for Arabic) and arabic_words_are_joined_and_read_right_to_left, text other_scripts_fall_back_to_a_plain_system_family and the script classification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
921f0dbdbe
commit
98a6a3a041
@@ -5,6 +5,7 @@ use effectcraft_engine::Session;
|
||||
use effectcraft_ui_egui::EffectcraftApp;
|
||||
use egui::{Event, Key, Modifiers, PointerButton, Pos2, pos2};
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::{NodeT, Queryable};
|
||||
use serde_json::json;
|
||||
|
||||
fn harness() -> (Harness<'static, EffectcraftApp>, u64) {
|
||||
@@ -422,3 +423,54 @@ fn ctrl_click_on_the_time_display_toggles_timecode_and_frames() {
|
||||
click_with(&mut h, at, Modifiers::COMMAND);
|
||||
assert_eq!(style(&h), TimeDisplayStyle::Timecode);
|
||||
}
|
||||
|
||||
/// Hold Alt and Shift and let go of them, as Windows' keyboard-layout hotkey does; `shift_first`
|
||||
/// releases Shift before Alt.
|
||||
fn switch_layout(h: &mut Harness<'_, EffectcraftApp>, shift_first: bool) {
|
||||
let held = if shift_first { Modifiers::ALT } else { Modifiers::SHIFT };
|
||||
for m in [Modifiers::ALT, Modifiers::ALT | Modifiers::SHIFT, held, Modifiers::NONE] {
|
||||
h.input_mut().events.push(Event::ModifiersChanged(m));
|
||||
h.step();
|
||||
}
|
||||
h.run_steps(2);
|
||||
}
|
||||
|
||||
/// #394: switching the keyboard layout to Arabic with Alt+Shift while a name is being typed
|
||||
/// leaves the field with the keyboard: releasing Shift before Alt left Alt held alone, which
|
||||
/// counted as an Alt tap, so the menu bar took the keyboard, the rename ended and the Arabic
|
||||
/// letters went nowhere. Layer and Project names keep what is typed in any script.
|
||||
#[test]
|
||||
fn a_layout_switch_keeps_the_name_field_and_arabic_names_are_kept() {
|
||||
let (mut h, comp) = harness();
|
||||
let layer = h.state_mut().session.execute("layer.newNull", json!({})).unwrap()["layer"].as_u64().unwrap();
|
||||
h.run_steps(3);
|
||||
let layer_name =
|
||||
|h: &Harness<'_, EffectcraftApp>| h.state().session.active_comp().unwrap().layer(effectcraft_engine::project::LayerId(layer)).unwrap().name.clone();
|
||||
let p = center(&h, &format!("timeline.layer.{layer}.row"));
|
||||
click(&mut h, p, 2);
|
||||
assert!(h.state().auto.find(&format!("timeline.layer.{layer}.nameEdit")).is_some(), "double-click opened the rename field");
|
||||
for shift_first in [true, false] {
|
||||
switch_layout(&mut h, shift_first);
|
||||
assert!(h.state().auto.find(&format!("timeline.layer.{layer}.nameEdit")).is_some(), "the rename field stays open");
|
||||
type_text(&mut h, if shift_first { "طبقة " } else { "مرحبا" });
|
||||
}
|
||||
key(&mut h, Key::Enter);
|
||||
assert_eq!(layer_name(&h), "طبقة مرحبا");
|
||||
// The Project panel's rename field, with Hebrew, Devanagari and Thai.
|
||||
let p = center(&h, &format!("project.item.{comp}.name"));
|
||||
click(&mut h, p, 1);
|
||||
key(&mut h, Key::Enter);
|
||||
switch_layout(&mut h, true);
|
||||
type_text(&mut h, "שכבה नाम ชื่อ");
|
||||
key(&mut h, Key::Enter);
|
||||
assert_eq!(h.state().session.project.items.values().find(|i| i.id.0 == comp).unwrap().name, "שכבה नाम ชื่อ");
|
||||
// A plain Alt tap still takes the keyboard to the menu bar (#279).
|
||||
if !cfg!(target_os = "macos") {
|
||||
h.input_mut().events.push(Event::ModifiersChanged(Modifiers::ALT));
|
||||
h.step();
|
||||
h.input_mut().events.push(Event::ModifiersChanged(Modifiers::NONE));
|
||||
h.run_steps(2);
|
||||
let focused = h.query_by(|n| n.is_focused()).and_then(|n| n.accesskit_node().label()).unwrap_or_default();
|
||||
assert_eq!(focused.trim(), "File", "Alt focused the menu bar");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user