Font hinting on Linux
Martin Fox
martin at martinfox.com
Thu Aug 8 17:38:10 UTC 2024
(OK, I’m caught up now. Forget whatever I said about hinting.)
I think there is a bug here. LCD text with the software renderer produces particularly bad results. Part of the code is shifting the glyphs along the X axis to set up the LCD shader even though it’s not used with the software renderer. The software renderer is then truncating to the nearest pixel boundary. The result is that glyphs at a fractional X of 0.8333 or less move left and all others move right.
Rounding to the nearest pixel boundary produces better results (in line with grayscale text) though the only really clean results come from using LCD text with the hardware pipeline.
I ended up using the software renderer by accident; I’m running in a VM and get the software renderer unless I force the GPU.
Martin
> On Aug 5, 2024, at 8:32 AM, Martin Fox <martin at martinfox.com> wrote:
>
> I don’t see how hinting issues can cause this degree of character misplacement. This looks more like, say, a glyph cache bug.
>
> I had no problem reproducing this with the software pipeline. When I force the GPU I get much better results (prism.forceGPU=true). In both cases the text is a little on the fuzzy side but the es2 pipeline is placing the glyphs correctly.
>
>> On Aug 4, 2024, at 9:09 PM, quizynox <quizynox at gmail.com> wrote:
>>
>> Hello,
>>
>> Thanks for the answer. I've found a couple of very long but very informative threads that have given me some pointers.
>>
>> Poor quality font rendering
>> https://mail.openjdk.org/pipermail/openjfx-dev/2013-August/009958.html
>>
>> The crisp fonts saga
>> https://mail.openjdk.org/pipermail/openjfx-dev/2023-December/044234.html
>>
>> In my case there were two problems:
>>
>> - I had SceneAntialiasing enabled, which seems to prevent -fx-smoothing-type=lcd from working
>> - I forgot that -fx-smoothing-type is only enabled for .text nodes, but not for all Text nodes by default
>>
>> I also assumed that Linux fontconfig settings would have some effect on JavaFX font rendering, but judging from tests this isn't the case. Perhaps the only thing that matters is freetype compilation flags. I've found that Fedora enabled ClearType font rendering some time ago (https://www.phoronix.com/news/Fedora-ClearType-Subpixel-Font).
>>
>> As for -fx-smooth-type=gray, with some fonts such as Open Sans, Liberation Sans or Montserrat it may look quite close to acceptable.
>>
>> вс, 4 авг. 2024 г. в 01:41, Philip Race <philip.race at oracle.com <mailto:philip.race at oracle.com>>:
>>> There's not many knobs available. Hinting is not enabled - and that's
>>> commonly the case on modern plartforms.
>>> LCD is your best option for readibility of static text, which is why it
>>> is the default for UI Controls,
>>> It should reduce the pixel grid fitting uneveness you highlight but
>>> doesn't eliminate it.
>>> Note : this presumes that the freetype on your system enables LCD .. if
>>> it doesn't there's nothing FX can do about that.
>>>
>>> -phil.
>>>
>>>
>>> On 8/2/24 10:43 AM, quizynox at gmail.com <mailto:quizynox at gmail.com> wrote:
>>> > Hello,
>>> >
>>> > Sorry for asking here, but I seem to have tried everything I could
>>> > find on SO/Reddit/JBS etc. Could someone please share what font
>>> > settings I should be using to get decent font hinting on Linux? Please
>>> > see the screenshot.
>>> >
>>> > https://drive.google.com/file/d/1gXYXzbcq4cHmZpza20yQJHfs0pMbgiZa/view
>>> >
>>> > I'm not very picky, but the font I see is just not suitable for
>>> > presenting app to customers. I've tried enabling and disabling hinting
>>> > and autohinting, using different hinting styles, changing the font
>>> > smoothing type and prism.lcdtext etc. Unfortunately no matter what I
>>> > do, the font hinting is always bad.
>>> >
>>> > Fedora, KDE, all latest versions.
>>> >
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20240808/35184bca/attachment.htm>
More information about the openjfx-dev
mailing list