Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use custom fonts only on Linux #204

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading