Skip to content

Commit

Permalink
use custom fonts only on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Apr 10, 2024
1 parent d19ba8e commit 5c2a07c
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
}
}
}
}
Expand Down

0 comments on commit 5c2a07c

Please sign in to comment.