Some feature requests/improvement suggestions for the JavaFX Font API

Andy Goryachev andy.goryachev at oracle.com
Mon Dec 1 20:10:25 UTC 2025


We do care.

Presently, there is a number of tickets in JBS complaining about fonts, for example


JDK-8344037<https://bugs.openjdk.org/browse/JDK-8344037> Font.loadFont() loads light/thin fonts as fonts with distinct families.

JDK-8087799<https://bugs.openjdk.org/browse/JDK-8087799> Unable to choose semibold fonts using CSS font-weight

JDK-8310565<https://bugs.openjdk.org/browse/JDK-8310565> [macos]When setting the font family for text, the Regular font is not being used

JDK-8209435<https://bugs.openjdk.org/browse/JDK-8209435> [macOS] Text with bold font weight rendered as normal text when TTC font is used

JDK-8310663<https://bugs.openjdk.org/browse/JDK-8310663> CSS parser can read all the font related properties, except for some font-family

JDK-8088391<https://bugs.openjdk.org/browse/JDK-8088391> javafx.scene.text.Font broken for families with more weights than Regular & Bold; especially on Mac

JDK-8190855<https://bugs.openjdk.org/browse/JDK-8190855> The text will be invisible when choosing different fonts of "Noto Sans" type

JDK-8176835<https://bugs.openjdk.org/browse/JDK-8176835> [macosx] System font cannot be boldened

JDK-8088257<https://bugs.openjdk.org/browse/JDK-8088257> support for both English and native font names

JDK-8089128<https://bugs.openjdk.org/browse/JDK-8089128> Font.getFontNames() sometimes returns duplicated font names.

JDK-8089450<https://bugs.openjdk.org/browse/JDK-8089450> Inconsistent naming for fonts in the 'Tahoma' family.

JDK-8090423<https://bugs.openjdk.org/browse/JDK-8090423> [Font] Support Font Weights other than Bold and Regular, like Light

JDK-8090628<https://bugs.openjdk.org/browse/JDK-8090628> Font - add getters for weight and posture

JDK-8092264<https://bugs.openjdk.org/browse/JDK-8092264> Support and document use of more fonts variants

(There might be more, I just did a quick query)

Are there any issues listed below that might be missing from JBS?

-andy




From: openjfx-dev <openjfx-dev-retn at openjdk.org> on behalf of Glavo <zjx001202 at gmail.com>
Date: Friday, November 28, 2025 at 07:10
To: openjfx-dev <openjfx-dev at openjdk.org>
Subject: Re: Some feature requests/improvement suggestions for the JavaFX Font API

Does anyone care about these issues?

Glavo

On Mon, Jul 21, 2025 at 2:29 AM Glavo <zjx001202 at gmail.com<mailto:zjx001202 at gmail.com>> wrote:
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20251201/d79ea368/attachment-0001.htm>


More information about the openjfx-dev mailing list