question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom desktop font?

See original GitHub issue

My friend complained to me that the font was not clear. image image

So we can add a custom font setting in desktop. Even if this setting is not displayed.

One of my idea:

Index: desktop/src/com/unciv/app/desktop/NativeFontDesktop.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/desktop/src/com/unciv/app/desktop/NativeFontDesktop.kt b/desktop/src/com/unciv/app/desktop/NativeFontDesktop.kt
--- a/desktop/src/com/unciv/app/desktop/NativeFontDesktop.kt	(revision fef993d5dca34f871f7a45a585cae7a73be77d6b)
+++ b/desktop/src/com/unciv/app/desktop/NativeFontDesktop.kt	(date 1647660638627)
@@ -1,6 +1,10 @@
 package com.unciv.app.desktop
 
+import com.badlogic.gdx.files.FileHandle
 import com.badlogic.gdx.graphics.Pixmap
+import com.unciv.JsonParser
+import com.unciv.logic.GameSaver
+import com.unciv.models.metadata.GameSettings
 import com.unciv.ui.utils.NativeFontImplementation
 import java.awt.*
 import java.awt.image.BufferedImage
@@ -8,7 +12,11 @@
 
 class NativeFontDesktop(private val size: Int) : NativeFontImplementation {
     private val font by lazy {
-        Font("", Font.PLAIN, size)
+        val settings = JsonParser().getFromJson(
+            GameSettings::class.java,
+            FileHandle(GameSaver.settingsFileName)
+        )
+        Font(settings.desktopFontFamily, Font.PLAIN, size)
     }
     private val metric by lazy {
         val bi = BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR)
Index: core/src/com/unciv/models/metadata/GameSettings.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/src/com/unciv/models/metadata/GameSettings.kt b/core/src/com/unciv/models/metadata/GameSettings.kt
--- a/core/src/com/unciv/models/metadata/GameSettings.kt	(revision fef993d5dca34f871f7a45a585cae7a73be77d6b)
+++ b/core/src/com/unciv/models/metadata/GameSettings.kt	(date 1647660638622)
@@ -19,6 +19,7 @@
     var checkForDueUnits: Boolean = true
     var singleTapMove: Boolean = false
     var language: String = "English"
+    var desktopFontFamily: String = ""
     @Transient
     var locale: Locale? = null
     var resolution: String = "900x600" // Auto-detecting resolution was a BAD IDEA since it needs to be based on DPI AND resolution.

Preview font change by 黑体 with Simplified-Chinese

image image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:25 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
HAHH9527commented, Mar 19, 2022

If users want choose less readable fonts, this should probably be their power too.

0reactions
HAHH9527commented, Mar 21, 2022

So…only for Desktop if I’m understanding everything correctly? Would still be glad to see this implemented since Windows default Korean font straight up sucks.

This support all desktop device and Android. At first, I just wanted to support the desktop. @SomeTroglodyte provides code for Android device support.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Change the Desktop Font - Computer Hope
Choose a font · Open the Windows Control Panel. · If your Control Panel uses the Category view mode, click the Appearance and...
Read more >
How to Change the Default System Font on Windows 10
Open the Settings app. In Settings, click “Personalization,” then select “Fonts” in the left sidebar. · Open Notepad · Save the new default...
Read more >
Add a font - Microsoft Support
If you want to see what a font looks like, open the Fonts folder, right-click the font file, and then click Preview. Another...
Read more >
Font Support - Fontspring
Fontspring Basics. Account Support · Checkout and Billing. Licenses. Desktop Licenses · Web Font Licenses. Font Support. Install Guide · Using your Fonts....
Read more >
How to Install Custom Fonts on Your Computer [Quick Tip]
How to Install Fonts on a PC · 1) Shut down any program you want to use the font in. · close_ppt ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found