Skip to content

Lightweight native Discord client for Windows, Linux and macOS, written in Rust. No Electron, no browser engine.

Show Thai text on Windows instead of boxes (#54)

Bank5caa0a57b031
diff --git a/apps/rustcord/src/style.rs b/apps/rustcord/src/style.rs
index 4d910cc..f0fbe54 100644
--- a/apps/rustcord/src/style.rs
+++ b/apps/rustcord/src/style.rs
@@ -823,6 +823,9 @@ pub fn install_fonts(ctx: &egui::Context) {
("himalaya", "C:\\Windows\\Fonts\\himalaya.ttf", false),
("tai-le", "C:\\Windows\\Fonts\\taile.ttf", false),
("mongolian-baiti", "C:\\Windows\\Fonts\\monbaiti.ttf", false),
+ // Thai (none of the above has it): Leelawadee UI, which Chrome
+ // picks for Thai on Windows.
+ ("leelawadee-ui", "C:\\Windows\\Fonts\\LeelawUI.ttf", false),
// Windows 11's catch-all for the rest (𐙚 ᭡ ꪆ ᰔ ᯓ 𖹭); Windows 10 lacks it.
("sans-serif-collection", "C:\\Windows\\Fonts\\SansSerifCollection.ttf", false),
]
@@ -908,6 +911,11 @@ pub fn install_fonts(ctx: &egui::Context) {
fonts.font_data.insert("segoe-ui-bold".into(), data);
bold.insert(0, "segoe-ui-bold".into());
}
+ // Thai in bold; otherwise the regular Leelawadee UI is found first.
+ if let Some(data) = font_file("C:\\Windows\\Fonts\\LeelaUIb.ttf") {
+ fonts.font_data.insert("leelawadee-ui-bold".into(), data.only(thai));
+ bold.insert(0, "leelawadee-ui-bold".into());
+ }
if let Some(data) = font_file("C:\\Windows\\Fonts\\arialbd.ttf") {
fonts.font_data.insert("arial-rtl-bold".into(), data.only(hebrew_or_arabic));
bold.insert(0, "arial-rtl-bold".into());
@@ -993,6 +1001,11 @@ pub fn install_fonts(ctx: &egui::Context) {
#[cfg(windows)]
const ARIAL_RTL: &str = "arial-rtl";
+/// Thai letters, vowels, tone marks and digits.
+fn thai(c: char) -> bool {
+ matches!(c as u32, 0x0E00..=0x0E7F)
+}
+
/// Hebrew and Arabic letters, marks, digits and presentation forms.
fn hebrew_or_arabic(c: char) -> bool {
matches!(c as u32, 0x0590..=0x06FF | 0x0750..=0x077F | 0x08A0..=0x08FF | 0xFB1D..=0xFDFF | 0xFE70..=0xFEFE)