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:
bflatastic
2026-10-10 00:53:21 +07:00
co-authored by Claude Opus 5.5
parent 921f0dbdbe
commit 98a6a3a041
5 changed files with 275 additions and 47 deletions
+9 -5
View File
@@ -114,27 +114,31 @@ pub fn active(ctx: &Context) -> bool {
ctx.data(|d| d.get_temp(active_id())).unwrap_or(false)
}
/// Alt pressed and released with nothing else in between (no key, click or wheel), off macOS.
/// Alt pressed and released with nothing else in between (no other modifier, key, click or wheel),
/// off macOS. Alt only counts when it went down with no other modifier held: Windows switches the
/// keyboard layout with Alt+Shift, and releasing Shift first leaves Alt held alone, which must not
/// take the keyboard from the field being typed in (#394).
fn alt_tapped(ctx: &Context) -> bool {
if cfg!(target_os = "macos") {
return false;
}
let mut armed: bool = ctx.data(|d| d.get_temp(alt_id())).unwrap_or(false);
// (armed, the modifiers held after the last change)
let (mut armed, mut held): (bool, Modifiers) = ctx.data(|d| d.get_temp(alt_id())).unwrap_or_default();
let mut tapped = false;
ctx.input(|i| {
for e in &i.events {
match e {
Event::ModifiersChanged(m) if *m == Modifiers::ALT => armed = true,
Event::ModifiersChanged(m) => {
tapped |= armed && *m == Modifiers::NONE;
armed = false;
armed = *m == Modifiers::ALT && held == Modifiers::NONE;
held = *m;
}
Event::PointerMoved(_) | Event::MouseMoved(_) | Event::Zoom(_) => {}
_ => armed = false,
}
}
});
ctx.data_mut(|d| d.insert_temp(alt_id(), armed));
ctx.data_mut(|d| d.insert_temp(alt_id(), (armed, held)));
tapped
}