On Wed, 18 Nov 2026 21:54:01 GMT, Phil Race <[email protected]> wrote:

> This updates a previous fix https://github.com/openjdk/jdk/pull/33761 to only 
> skip over nfonts / 2 variable fonts.
> 
> So if a system has (say) just one font and it is a variable font, we'll now 
> accept it which is better than no fonts.
> 
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

src/java.desktop/unix/native/common/awt/fontpath.c line 1083:

> 1081: 
> 1082:             fontformat = NULL;
> 1083:             if ((fontCount == 0) && (j < (nfonts / 2))) {

IIUC, an edge case is possible on a system with only two fonts.
If `FcFontSort` returns a usable variable font first and an unsupported font 
(e.g. a bitmap font) second, the first is skipped and the second is rejected by 
the JDK.
So we can end up with `fcFirstFontID` unset, while we could have used the first 
font.

Wouldn’t it be safer to retry the search from the start with variable fonts 
allowed if the first pass found no usable font (`fontCount == 0`)?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/33957#discussion_r4685104845

Reply via email to