RFR: 8281327: JavaFX does not support fonts installed per-user on Windows 10/11

Jose Pereda jpereda at openjdk.org
Tue Jan 31 17:40:50 UTC 2023


On Tue, 31 Jan 2023 16:47:01 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> This PR simply applies the patch from [JDK-8218914](https://bugs.openjdk.org/browse/JDK-8218914) that solved the same issue for the JDK.
>> 
>> I've tested it on Windows 11 (Version 22H2 Build 22621.1105). 
>> 
>> I have the Roboto font installed under C:\Users%user\AppData\Local\Microsoft\Windows\Fonts
>> and with this PR, -Dprism.debugfonts shows:
>> 
>> 
>> ...
>> font=segoe ui historic file=seguihis.ttf
>> font=roboto file=C:\Users%user\AppData\Local\Microsoft\Windows\Fonts\Roboto-Regular.ttf
>> font=yu mincho file=yumin.ttf
>> ...
>> 
>> 
>> Also, I can see that the font is picked in a simple JavaFX application.
>> Without this PR, the font is not used, and defaults to a system one. 
>> 
>> I don't think I can add this as a system/manual test to the PR, though.
>
> modules/javafx.graphics/src/main/native-font/fontpath.c line 572:
> 
>> 570:     if (ret != ERROR_SUCCESS ||
>> 571:         dwMaxValueNameLen >= MAX_BUFFER ||
>> 572:         dwMaxValueDataLen >= MAX_BUFFER) {
> 
> This implementation instantly fails if _any_ value or data exceeds `MAX_BUFFER`. Wouldn't it be better to only skip the values that are too large, instead of ignoring all values entirely?
> 
> Instead of using `RegQueryInfoKeyW`, the [documentation](https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regenumvaluew) suggests the following approach:
> 
>> To enumerate values, an application should initially call the RegEnumValue function with the dwIndex parameter set to zero. The application should then increment dwIndex and call the RegEnumValue function until there are no more values (until the function returns ERROR_NO_MORE_ITEMS).

Please note that this is just a refactoring of the existing code, extracting a method so that it can be called twice, and it is also what the JDK is doing. 
If the affected code needs changes, maybe that is for a follow up.

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

PR: https://git.openjdk.org/jfx/pull/1017


More information about the openjfx-dev mailing list