From 948d28ab93b643b8817ba335406ff58bc9f258fb Mon Sep 17 00:00:00 2001 From: Davit Matchakhelidze Date: Fri, 23 Oct 2026 02:16:03 +0400 Subject: [PATCH] Draw Georgian with the system's Georgian font MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit None of the bundled faces (Inter, Archivo, Geist Mono) has Georgian letters, so Georgian text would draw as boxes. Georgian joins the CJK languages' mechanism: `Script::Georgian`, and cjk_font.rs looks for the system's Georgian face — SF Georgian, then Arial Unicode MS on macOS; Sylfaen on Windows; Noto Sans Georgian or DejaVu Sans on Linux and FreeBSD — and adds it behind the bundled faces. Nothing is bundled. Where the system has none, and on the web, a Georgian interface stays in English and Settings says why, as for the CJK languages; the hint now names Noto Sans Georgian too. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YMTAbGNRxnMEzRvYnQGphF --- AGENTS.md | 3 +- crates/ui-egui/src/cjk_font.rs | 49 +++++++++++++++++++++++++++ crates/ui-egui/src/i18n/lang.rs | 14 ++++---- crates/ui-egui/src/settings_dialog.rs | 2 +- 4 files changed, 60 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e1d78929..f4cf7e9e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -95,7 +95,8 @@ means adding its row to every catalog marked `complete_menus` (the `*.tsv` files the English text, never through another catalog. Product and app names (ArtCraft Launcher, Craft App Suite, PhotoCraft…) stay in English. A CJK language is drawn with the system's own CJK font (`crates/ui-egui/src/cjk_font.rs`, desktop -only; English where there is none): never bundle a CJK font, they are 10 MB and more. +only; English where there is none): never bundle a CJK font, they are 10 MB and more. Georgian +borrows the system's Georgian font the same way. ### Other rules diff --git a/crates/ui-egui/src/cjk_font.rs b/crates/ui-egui/src/cjk_font.rs index a02e0303..38ccd809 100644 --- a/crates/ui-egui/src/cjk_font.rs +++ b/crates/ui-egui/src/cjk_font.rs @@ -1,6 +1,8 @@ //! A CJK font from the operating system, for the CJK interface languages. The bundled faces have //! no CJK glyphs, and a CJK font is too large to ship (10 MB or more), so the desktop build //! borrows the one every system that can show them already has. Desktop only. +//! +//! Georgian, which the bundled faces don't draw either, borrows its system face the same way. use std::path::{Path, PathBuf}; @@ -40,6 +42,7 @@ fn script_name(script: Script) -> &'static str { match script { Script::Chinese => "Chinese", Script::Japanese => "Japanese", + Script::Georgian => "Georgian", } } @@ -48,6 +51,7 @@ fn script_families(script: Script) -> &'static str { match script { Script::Chinese => "PingFang SC, Hiragino Sans GB, Heiti SC, Microsoft YaHei, SimSun, Noto Sans CJK SC and WenQuanYi", Script::Japanese => "Hiragino Sans, Yu Gothic, Meiryo, MS Gothic, Noto Sans CJK JP, Noto Sans JP, IPAGothic and TakaoGothic", + Script::Georgian => "SF Georgian, Arial Unicode MS, Sylfaen, Noto Sans Georgian and DejaVu Sans", } } @@ -123,6 +127,7 @@ fn candidates(script: Script) -> Vec { match script { Script::Chinese => chinese_candidates(), Script::Japanese => japanese_candidates(), + Script::Georgian => georgian_candidates(), } } @@ -255,6 +260,50 @@ fn japanese_candidates() -> Vec { out } +/// Where each system keeps a Georgian font, best first. These faces are small (about 0.1–1 MB), +/// except Arial Unicode MS, which macOS ships too. +fn georgian_candidates() -> Vec { + let mut out = Vec::new(); + let mut add = |path: PathBuf, family: &'static str| out.push(Candidate { path, family }); + #[cfg(target_os = "macos")] + { + // SF Georgian is the system UI face for Georgian; its family name starts with a dot, as + // macOS's hidden UI faces do. + add("/System/Library/Fonts/SFGeorgian.ttf".into(), ".SF Georgian"); + add("/System/Library/Fonts/Supplemental/Arial Unicode.ttf".into(), "Arial Unicode MS"); + add("/Library/Fonts/Arial Unicode.ttf".into(), "Arial Unicode MS"); + } + #[cfg(target_os = "windows")] + { + let root = std::env::var_os("SystemRoot").map_or_else(|| PathBuf::from(r"C:\Windows"), PathBuf::from); + add(root.join("Fonts").join("sylfaen.ttf"), "Sylfaen"); + } + #[cfg(all(unix, not(target_os = "macos")))] + { + // Debian/Ubuntu, Arch, Fedora (static and variable) and FreeBSD's ports. + for path in [ + "/usr/share/fonts/truetype/noto/NotoSansGeorgian-Regular.ttf", + "/usr/share/fonts/noto/NotoSansGeorgian-Regular.ttf", + "/usr/share/fonts/google-noto/NotoSansGeorgian-Regular.ttf", + "/usr/share/fonts/google-noto-vf/NotoSansGeorgian[wght].ttf", + "/usr/local/share/fonts/noto/NotoSansGeorgian-Regular.ttf", + ] { + add(path.into(), "Noto Sans Georgian"); + } + // DejaVu Sans draws Georgian too, and most desktops have it. + for path in [ + "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", + "/usr/share/fonts/TTF/DejaVuSans.ttf", + "/usr/share/fonts/dejavu-sans-fonts/DejaVuSans.ttf", + "/usr/share/fonts/dejavu/DejaVuSans.ttf", + "/usr/local/share/fonts/dejavu/DejaVuSans.ttf", + ] { + add(path.into(), "DejaVu Sans"); + } + } + out +} + /// `file` in macOS's downloaded font assets: /// `/System/Library/AssetsV2/com_apple_MobileAsset_Font*/*.asset/AssetData/`. #[cfg(target_os = "macos")] diff --git a/crates/ui-egui/src/i18n/lang.rs b/crates/ui-egui/src/i18n/lang.rs index 7a26a40b..affec016 100644 --- a/crates/ui-egui/src/i18n/lang.rs +++ b/crates/ui-egui/src/i18n/lang.rs @@ -7,17 +7,18 @@ use super::detect::system_lang; /// The writing system a language is drawn in, and so the system font it needs. Languages that /// share one can share a face; Simplified and Traditional Chinese do not (they want different -/// faces), so each script is its own. The bundled faces have no CJK glyphs, so a language with a -/// script borrows a system font for it (`crate::theme::cjk_font`). +/// faces), so each script is its own. The bundled faces have no CJK or Georgian glyphs, so a +/// language with a script borrows a system font for it (`crate::theme::cjk_font`). #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Script { Chinese, Japanese, + Georgian, } impl Script { /// Every script a language can be written in. - pub const ALL: [Script; 2] = [Script::Chinese, Script::Japanese]; + pub const ALL: [Script; 3] = [Script::Chinese, Script::Japanese, Script::Georgian]; } /// One supported UI language. @@ -29,7 +30,8 @@ pub struct LangInfo { pub name: &'static str, /// The language's name in English, shown instead where its own script can't be drawn. pub english_name: &'static str, - /// The writing system this language is drawn in, or `None` if it needs no system CJK font. + /// The writing system this language is drawn in, or `None` if it needs no system font + /// (CJK, Georgian). pub script: Option