Giter Club home page Giter Club logo

Comments (5)

SomeTroglodyte avatar SomeTroglodyte commented on May 10, 2024

Debugging:

It doesn't matter if you ask Java for "", "SansSerif" or null: You get a java.awt.Font with the internal font2DHandle pointing to a CompositeFont with interesting attributes:
componentNames = ["Arial", "Wingdings", "Symbol", "Segoe UI Symbol", "Segoe UI Emoji", +23 more]...
And: exclusionRanges = [1792, 7423, 7552, 7839, 7936, 8215, 8224, 8363, 8365, 8376, 8379, 8380, 8382, 9471, 9473, 9473, 9475, 9483, 9485, 9487, 9489, 9491, 9493, 9495, 9497, 9499, 9501, 9507, 9509, 9515, 9517, 9523, 9525, 9531, 9533, 9551, 9581, 63743, 13, 34, 36, 41, 43, 47, 58, 168, 170, 173, 175, 732, 8194, 8195, 8197, 8197, 8205, 8205, 8211, 8212, 8216, 8218, 8220, 8222, 8224, 8226, 8230, 8230, 8240, 8240, 8249, 8250, 8260, 8260, 8364, 8364, 8419, 8419, 8486, 8486, 8592, 8595, 8602, 8616, 8619, 8703, 8710, 8710, 8719, 8719, 8721, 8722, 8729, 8730, 8734, 8734, 8747, 8747, 8776, 8776, 8800, 8800, +182 more] - and 8734 is the infinity symbol!

So someone at Java decided to exclude it! 🙈 They go out of their way to combine elements from different system fonts, only to give you something with worse Unicode support than the individual system fonts themselves. 🧠 đŸ„Ł 🧟

from unciv.

SomeTroglodyte avatar SomeTroglodyte commented on May 10, 2024

Confirmed - Problem does not exist on Mint 21.

Another possible patch:

(force-redirect default to Segoe UI)

Index: desktop/src/com/unciv/app/desktop/UncivWindowListener.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/desktop/src/com/unciv/app/desktop/UncivWindowListener.kt b/desktop/src/com/unciv/app/desktop/UncivWindowListener.kt
--- a/desktop/src/com/unciv/app/desktop/UncivWindowListener.kt	(revision 4503e724006690a334ef01f351c61948f1efa8ac)
+++ b/desktop/src/com/unciv/app/desktop/UncivWindowListener.kt	(date 1709641530970)
@@ -80,7 +80,7 @@
          *  (which, by the way, says "Incomplete implementation to support demos.")
          */
         val user32: User32? = try {
-            if (System.getProperty("os.name")?.contains("Windows") == true) {
+            if (SystemUtils.isWindows()) {
                 Native.load(User32::class.java)
             } else {
                 null
Index: desktop/src/com/unciv/app/desktop/SystemUtils.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/desktop/src/com/unciv/app/desktop/SystemUtils.kt b/desktop/src/com/unciv/app/desktop/SystemUtils.kt
--- a/desktop/src/com/unciv/app/desktop/SystemUtils.kt	(revision 4503e724006690a334ef01f351c61948f1efa8ac)
+++ b/desktop/src/com/unciv/app/desktop/SystemUtils.kt	(date 1709642097609)
@@ -5,12 +5,18 @@
 
 object SystemUtils {
 
+    /** Detects if we're running on Windows via Java's os.name */
+    // Note com.badlogic.gdx.utils.SharedLibraryLoader.isWindows basically does the same
+    // but seeing as it fails isLinux on FreeBSD - cheap enough to do it again.
+    fun isWindows() = System.getProperty("os.name")?.isWindows() == true
+    private fun String.isWindows() = startsWith("Windows", ignoreCase = true)
+
     fun getSystemInfo(): String {
         val builder = StringBuilder()
 
         // Operating system
         val osName = System.getProperty("os.name") ?: "Unknown"
-        val isWindows = osName.startsWith("Windows", ignoreCase = true)
+        val isWindows = osName.isWindows()
         builder.append("OS: $osName")
         if (!isWindows) {
             val osInfo = listOfNotNull(System.getProperty("os.arch"), System.getProperty("os.version")).joinToString()
Index: desktop/src/com/unciv/app/desktop/DesktopFont.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/desktop/src/com/unciv/app/desktop/DesktopFont.kt b/desktop/src/com/unciv/app/desktop/DesktopFont.kt
--- a/desktop/src/com/unciv/app/desktop/DesktopFont.kt	(revision 4503e724006690a334ef01f351c61948f1efa8ac)
+++ b/desktop/src/com/unciv/app/desktop/DesktopFont.kt	(date 1709650568626)
@@ -30,7 +30,10 @@
         // System font
         else
         {
-            this.font = Font(fontFamilyData.invariantName, Font.PLAIN, size)
+            this.font = Font(fontFamilyData.invariantName.ifBlank {
+                // Java's default manages to give you a CompositeFont omitting the infinity symbol
+                if (SystemUtils.isWindows()) "Segoe UI" else null
+            }, Font.PLAIN, size)
         }
 
         val bufferedImage = BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR)

... but since I have no info on who else is affected, no PR.

from unciv.

yairm210 avatar yairm210 commented on May 10, 2024

Adding another custom emoji for infinity sounds a lot less error prone than forcing fonts, especially since user can change the font manually

from unciv.

yairm210 avatar yairm210 commented on May 10, 2024

It also won't break if Windows 14 decides to ship without this font

from unciv.

SomeTroglodyte avatar SomeTroglodyte commented on May 10, 2024

Adding another custom emoji for infinity

Well a patch for that is in #11257, although one should edit that image and push down the baseline before actually using. The gimp to do that before scaling losses is there too.

But - if no-one else complains, I'd say ignore, as it's an upstream bug, not ours.

from unciv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.