From 5b2921e616b1ad57ea91e0afb347861965f00fad Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 24 Oct 2026 22:42:28 -0400 Subject: [PATCH] Share Linux Noto directory list across Thai and Hebrew font lookups Removes the duplicated directory arrays flagged by SonarCloud new-code duplication. --- crates/ui-egui/src/theme.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index 07b240666..ba854fa64 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -645,19 +645,25 @@ fn cjk_hangul() -> Vec<(String, u32)> { } /// Thai faces. Windows ships Leelawadee UI and Tahoma/Microsoft Sans Serif (both carry Thai); +/// Linux font directories searched by the Thai and Hebrew faces, in priority order. +#[cfg(not(target_arch = "wasm32"))] +fn linux_noto_dirs() -> [&'static str; 5] { + [ + "/usr/share/fonts/truetype/noto", + "/usr/share/fonts/opentype/noto", + "/usr/share/fonts/truetype", + "/usr/share/fonts", + "/usr/share/fonts/chromeos/noto", // ChromeOS's Linux container (#1762) + ] +} + /// macOS has Thonburi; Linux usually has Noto Sans Thai or Garuda. #[cfg(not(target_arch = "wasm32"))] fn thai() -> Vec<(String, u32)> { let mac_sys = "/System/Library/Fonts"; let mac_sup = "/System/Library/Fonts/Supplemental"; let win = windows_fonts(); - let lin = [ - "/usr/share/fonts/truetype/noto", - "/usr/share/fonts/opentype/noto", - "/usr/share/fonts/truetype", - "/usr/share/fonts", - "/usr/share/fonts/chromeos/noto", // ChromeOS's Linux container (#1762) - ]; + let lin = linux_noto_dirs(); let mut v: Vec<(String, u32)> = vec![ (format!("{win}\\LeelawUI.ttf"), 0), // Leelawadee UI (format!("{win}\\tahoma.ttf"), 0), // Tahoma @@ -703,13 +709,7 @@ fn hebrew() -> Vec<(String, u32)> { let mac_sys = "/System/Library/Fonts"; let mac_sup = "/System/Library/Fonts/Supplemental"; let win = windows_fonts(); - let lin = [ - "/usr/share/fonts/truetype/noto", - "/usr/share/fonts/opentype/noto", - "/usr/share/fonts/truetype", - "/usr/share/fonts", - "/usr/share/fonts/chromeos/noto", // ChromeOS's Linux container (#1762) - ]; + let lin = linux_noto_dirs(); let mut v: Vec<(String, u32)> = vec![ (format!("{win}\\david.ttf"), 0), // David (format!("{win}\\frank.ttf"), 0), // FrankRuehl