From 5c2a07cf302505bc60bc0bbeb13423618d080453 Mon Sep 17 00:00:00 2001 From: zoff99 Date: Wed, 10 Apr 2024 15:06:39 +0200 Subject: [PATCH] use custom fonts only on Linux --- src/main/kotlin/Main.kt | 61 +++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index 3a6436f7..b008d4b9 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -1921,36 +1921,39 @@ private fun MainAppStart() // HINT: for some reason the fonts do not load on macOS if ((OperatingSystem.getCurrent() != OperatingSystem.MACOS) && (OperatingSystem.getCurrent() != OperatingSystem.MACARM)) { - if (use_custom_font_with_color_emoji) + if (OperatingSystem.getCurrent() == OperatingSystem.LINUX) { - // HINT: use a patched font that noto color emoji with regular chars like numbers and spaces removed - // this will show emojis in texts but use the default font as fallback for anything that is not an emoji - DefaultFont = FontFamily( - Font(resource = "fonts/Noto-COLRv1_normal_chars_removed.ttf", FontWeight.Normal, FontStyle.Normal), - Font(resource = "fonts/Noto-COLRv1_normal_chars_removed.ttf", FontWeight.SemiBold, FontStyle.Normal), - Font(resource = "fonts/Noto-COLRv1_normal_chars_removed.ttf", FontWeight.Bold, FontStyle.Normal), - // Font(resource = "fonts/NotoSans-Regular.ttf", FontWeight.Normal, FontStyle.Normal), - // Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.SemiBold, FontStyle.Normal), - // Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.Bold, FontStyle.Normal), - ) - /* - val default_font_file_with_path = RESOURCESDIR.toString() + "/" + "NotoSans-Regular.ttf" - Log.i(TAG, "font=" + default_font_file_with_path) - val f: java.awt.Font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, - File(default_font_file_with_path)) - val ge = GraphicsEnvironment.getLocalGraphicsEnvironment() - ge.registerFont(f) - */ - } - else - { - DefaultFont = FontFamily( - // Font(resource = "fonts/Ubuntu-R.ttf", FontWeight.Normal, FontStyle.Normal), - // Font(resource = "fonts/Ubuntu-B.ttf", FontWeight.Bold, FontStyle.Normal), - Font(resource = "fonts/NotoSans-Regular.ttf", FontWeight.Normal, FontStyle.Normal), - Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.SemiBold, FontStyle.Normal), - Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.Bold, FontStyle.Normal), - ) + if (use_custom_font_with_color_emoji) + { + // HINT: use a patched font that noto color emoji with regular chars like numbers and spaces removed + // this will show emojis in texts but use the default font as fallback for anything that is not an emoji + DefaultFont = FontFamily( + Font(resource = "fonts/Noto-COLRv1_normal_chars_removed.ttf", FontWeight.Normal, FontStyle.Normal), + Font(resource = "fonts/Noto-COLRv1_normal_chars_removed.ttf", FontWeight.SemiBold, FontStyle.Normal), + Font(resource = "fonts/Noto-COLRv1_normal_chars_removed.ttf", FontWeight.Bold, FontStyle.Normal), + // Font(resource = "fonts/NotoSans-Regular.ttf", FontWeight.Normal, FontStyle.Normal), + // Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.SemiBold, FontStyle.Normal), + // Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.Bold, FontStyle.Normal), + ) + /* + val default_font_file_with_path = RESOURCESDIR.toString() + "/" + "NotoSans-Regular.ttf" + Log.i(TAG, "font=" + default_font_file_with_path) + val f: java.awt.Font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, + File(default_font_file_with_path)) + val ge = GraphicsEnvironment.getLocalGraphicsEnvironment() + ge.registerFont(f) + */ + } + else + { + DefaultFont = FontFamily( + // Font(resource = "fonts/Ubuntu-R.ttf", FontWeight.Normal, FontStyle.Normal), + // Font(resource = "fonts/Ubuntu-B.ttf", FontWeight.Bold, FontStyle.Normal), + Font(resource = "fonts/NotoSans-Regular.ttf", FontWeight.Normal, FontStyle.Normal), + Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.SemiBold, FontStyle.Normal), + Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.Bold, FontStyle.Normal), + ) + } } } }