Hi, We noticed that the Font API had many bugs and inconsistencies, and was missing a lot of functionality. Unfortunately, I don't have enough knowledge in this field to solve them. So I'm making some feature requests/improvement suggestions on this to see if anyone is interested.
1. Unify the meaning of "font family". Currently "font family" has different meanings on different platforms: - On Windows, it usually means the localized name of the font family name (nameID=1); - On Linux, it usually means the non-localized font family name (nameID=1, langID=0x0); - On macOS, it usually means the non-localized typographical family name (nameID=16, langID=0x0). This inconsistency makes the behavior of the program confusing and it is impossible to know what will happen without testing on multiple platforms. I want JavaFX to use the non-localized typographical family name (nameID=16, langID=0x0) on all platforms. The reason is that the font family name (nameID=1) of many fonts actually contains the font style information, and using it makes it difficult for us to select font style. For example, if we want to get JetBrains Mono Bold on Windows, we need to use Font.font("JetBrains Mono", FontWeight.BOLD, 13), but to get JetBrains Mono ExtraBold, we need to use Font.font("JetBrains Mono ExtraBold", FontWeight.NORMAL, 13). This is really frustrating :( Additionally, I encountered a bug on macOS that prevented me from selecting the font weight. I explained this issue in a previous email: https://mail.openjdk.org/pipermail/openjfx-dev/2025-July/055417.html 2. Make Font.font(String) accept both font name and font family name. I wish Font.font(String) could accept more names than just the font family name. As mentioned in the previous section, the current concept of font family names in JavaFX is confusing and often contains font style information. Therefore, it is very difficult to use the Font.font(String) in the correct way. If it would accept a variety of font names, both localized and non-localized, it would be less difficult to use. 3. Add more methods to get font localized names I would like to get these methods in Font class to get the localized name of the font: - static Map<Locale, String> getLocalizedFamilyNames(String family) - static String getLocalizedFamilyName(String family, Locale locale) - static String getLocalizedFontNames(Locale locale) - static String getLocalizedFontNames(String family, Locale locale) - Map<Locale, String> getLocalizedNames() - String getLocalizedName(Locale locale) - Map<Locale, String> getLocalizedFamily() - String getLocalizedFamily(Locale locale) 4. More methods for handling font styles Right now we can only use FontWeight and FontPosture to select a font style when looking up a font, but the only way to get the style from a given Font object is Font::getStyle(), which is very asymmetrical. I would like to get these methods to handle font styles: - static List<String> getStyles(String family) - static Font font(String family, String style) - FontWeight getWeight() - FontPosture getPosture() 5. Support fallback fonts and CSS font list for UI controls 6. Provides a way to control the typographic features of fonts Refer to Flutter's FontFeature class: https://api.flutter.dev/flutter/dart-ui/FontFeature-class.html Glavo