RFR: 8357672: Extreme font sizes can cause font substitution
Phil Race
prr at openjdk.org
Mon Jun 2 15:07:54 UTC 2025
On Mon, 2 Jun 2025 11:19:48 GMT, Jayathirth D V <jdv at openjdk.org> wrote:
>> Instrumenting the existing ExtremeFontSizeTest.java, it was noted that the freetype code, when encountering a null return from getting a scaler context, would over-interpret this as a bad font.
>> The test was intended to check this wasn't happening by verifying metrics before and after using extreme sizes.
>> But the scenaro was not being detected by the test because a replacement font was substituted and it did not have zero metrics.
>> So the updated test checks that the metrics before and after are the same.
>> This new version of the test failed on Linux before the JDK source updates and passes afterwards.
>
> test/jdk/java/awt/FontMetrics/ExtremeFontSizeTest.java line 39:
>
>> 37: /*
>> 38: * @test
>> 39: * @bug 8328896 8357672
>
> I thought Freetype rasterizer is used on all platforms(Linux, Windows & macOS) by default. Since Freetype is part of JDK.
>
> When i run this test on macOS without any updates from this PR on baseline code, i see that all Fontmetrics in System.out() are non-zero and match before and after extreme parameters. Is this behaviour okay?
>
> I was expecting mismatch in FontMetrics on macOS also.
> If this test is supposed to catch issues on particular platforms. Do we need to make it specific to some platforms?
On mac, freetype is only used in a few cases - Type1 fonts and Font.loadFont.
The test is not Linux-specific, nor should it be constrained to Linux, the behaviour it validates applies to all platforms.
And if you look at the PR that introduced this test, it did update macOS and the test did identify issues on macOS.
So in short, no changes needed.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25511#discussion_r2121443937
More information about the client-libs-dev
mailing list