Bug 497819 - Full hinting (byte code interpreter) for fonts does not work
Summary: Full hinting (byte code interpreter) for fonts does not work
Status: RESOLVED UPSTREAM
Alias: None
Product: kde
Classification: I don't know
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs
URL: https://bugreports.qt.io/browse/QTBUG...
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-23 08:42 UTC by andrew
Modified: 2025-02-08 01:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
FontForge source for a TTF test font with byte code hinting instructions to clearly test hinting (4.02 KB, application/vnd.font-fontforge-sfd)
2024-12-23 08:42 UTC, andrew
Details
Compiled TTF test font with byte code hinting instructions to clearly test hinting (3.09 KB, application/octet-stream)
2024-12-23 08:45 UTC, andrew
Details
FTView showing the attached test font when hinting is disabled (8.51 KB, image/png)
2024-12-23 08:47 UTC, andrew
Details
FTView showing the attached test font when hinting is enabled (8.15 KB, image/png)
2024-12-23 08:47 UTC, andrew
Details
Emacs (using GTK3 and XWayland) demonstrating working hinting (6.82 KB, image/png)
2024-12-23 08:48 UTC, andrew
Details
Konsole with the test font at size at 10pt not showing hinting (12.30 KB, image/png)
2024-12-23 08:50 UTC, andrew
Details
Konsole with the test font at size at 24pt not showing hinting (17.91 KB, image/png)
2024-12-23 08:50 UTC, andrew
Details
Konsole with the test font at size at 25pt partly showing hinting (16.67 KB, image/png)
2024-12-23 08:51 UTC, andrew
Details
PySide6 script to test hinting with pure Qt (1.10 KB, text/x-python)
2025-02-03 09:04 UTC, andrew
Details
PySide6 script to test hinting with pure Qt (result) (70.57 KB, image/png)
2025-02-03 09:05 UTC, andrew
Details

Note You need to log in before you can comment on or make changes to this bug.
Description andrew 2024-12-23 08:42:49 UTC
Created attachment 176842 [details]
FontForge source for a TTF test font with byte code hinting instructions to clearly test hinting

SUMMARY

When I select full hinting from the Fonts panel in System Settings, KDE applications do not actually appear to use full hints, or at least not to use the hints in the byte code within TTF fonts.  

STEPS TO REPRODUCE

1. Use the System Settings to set hinting to full
1a. Verify that /etc/fonts/conf.d is set to full hinting
1b. Verify that ~/.config/fontconfig has nothing that overrides this
2. Run KDE Plasma on Wayland
3. Set Konsole, Kwrite, or other to KDE app to use a TTF font that includes byte code instructions for hinting (e.g., attached)
 
OBSERVED RESULT

The KDE app does not display text with hinting according to the byte code within the font.  Strongly-hinted fonts still appear blurry.

EXPECTED RESULT

KDE apps display text with hinting using the byte code within the font.

SOFTWARE/OS VERSIONS

Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.9.0
Qt Version: 6.8.1
Kernel Version: 6.12.5-200.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 32 ร— AMD Ryzen 9 7950X 16-Core Processor
Memory: 62.5 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 4090/PCIe/SSE2

ADDITIONAL INFORMATION

I first noticed this when I realized that Konsole, when set to my own coding font, was not using the hinting instructions that I had laboriously programmed in.  This was despite hinting being set to Full in the System Setting, /etc/fonts/conf.d/ being set to full hinting, ~/.Xresources being set to Xft.hintstyle: hintfull, and everything else that I could think of.

Graphical Emacs, built against GTK3 and using XWayland, correctly renders the full hinting.  The FreeType tool, ftview, also correctly displays fonts with byte code hinting, so this does not seem to be at the level of FreeType.

Since the effect of font hinting can be subtle, I have created the attached test font to clearly verify whether byte code hinting is working or not.  It has two glyphs:

- The `x` glyph has a glyph outline that displays an N (for not hinting), but uses byte code instructions to reposition the diagonal to a horizontal stem, making an H to demonstrate that byte code hinting is working.

- The `o` glyph displays three nested squares.  If byte code hinting is working, each square and the spaces between them should be exactly one pixel in thickness, regardless of font size.  (There may be some variation here horizontally depending on sub-pixel alignment settings, but certainly they should be aligned vertically to the pixel grid.)  Otherwise, if the squares are significantly thicker than a pixel at larger sizes, byte code hinting is not working.
Comment 1 andrew 2024-12-23 08:45:24 UTC
Created attachment 176843 [details]
Compiled TTF test font with byte code hinting instructions to clearly test hinting
Comment 2 andrew 2024-12-23 08:47:10 UTC
Created attachment 176844 [details]
FTView showing the attached test font when hinting is disabled
Comment 3 andrew 2024-12-23 08:47:39 UTC
Created attachment 176845 [details]
FTView showing the attached test font when hinting is enabled
Comment 4 andrew 2024-12-23 08:48:40 UTC
Created attachment 176846 [details]
Emacs (using GTK3 and XWayland) demonstrating working hinting
Comment 5 andrew 2024-12-23 08:50:29 UTC
Created attachment 176847 [details]
Konsole with the test font at size at 10pt not showing hinting
Comment 6 andrew 2024-12-23 08:50:51 UTC
Created attachment 176848 [details]
Konsole with the test font at size at 24pt not showing hinting
Comment 7 andrew 2024-12-23 08:51:14 UTC
Created attachment 176849 [details]
Konsole with the test font at size at 25pt partly showing hinting
Comment 8 andrew 2024-12-23 08:56:15 UTC
Additional note: weirdly, the behavior seems to change between 24pt and 25pt.  At 25pt and above, the `x` glyph changes from an N to an H, demonstrating that it is now interpreting the byte code.  And at 25pt and above, the `o` glyph collapses (despite showing just fine at very large sizes in FTView).
Comment 9 Nate Graham 2025-01-07 19:48:33 UTC
Thanks for the detailed bug report. To my knowledge, we don't do our own font rendering in KDE; this is done below us, in Qt level. Can you see if the same issues manifest on your system in a Qt app not built with any KDE frameworks? e.g. QBitTorrent. If they do, then it's a Qt issue, and the place to raise this will be https://bugreports.qt.io

Thanks a lot!
Comment 10 Bug Janitor Service 2025-01-22 03:47:40 UTC
๐Ÿ›๐Ÿงน โš ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 11 andrew 2025-02-03 09:04:50 UTC
Created attachment 177920 [details]
PySide6 script to test hinting with pure Qt
Comment 12 andrew 2025-02-03 09:05:17 UTC
Created attachment 177921 [details]
PySide6 script to test hinting with pure Qt (result)
Comment 13 andrew 2025-02-03 09:14:52 UTC
Thanks, Nate.

Now that I have some free time again, I rolled a quick PySide6 script to display my test font with pure Qt.  It looks like you were correct: it shows the same behavior as the KDE apps (script and screenshot attached), so it appears that I'll need to re-raise this with the Qt folks.

I had originally thought this might be a KDE issue since KDE does have configuration settings for fonts and font hinting and I'd thought maybe there was something in the way that it stored those settings and interacted with Qt (given that the Qt API allows for things like setting the hinting preference).
Comment 14 Nate Graham 2025-02-03 14:38:22 UTC
Happy to help! With all the information you're able to provide, I have no doubt that the Qt bug report you'll file will be actionable by the Qt devs.
Comment 15 andrew 2025-02-03 23:04:11 UTC
Followup:

Interestingly, searching their bug tracker to try to avoid a dupe, I came across https://bugreports.qt.io/browse/QTBUG-128874, which led me back to the related Bug 492918 here (which I see you'd responded to as well).

I gave it a shot changing my display scaling from 200% (integer scaling) to 100%, and the result was the hinting working perfectly on my pure Qt test.  I also noticed right away that Konsole was now clearly showing my coding font's hinting at the new tiny size.  I tested other scaling factors as well, and all showed broken hinting except for 100%.  (Also, I'm only using a single screen, so this shouldn't be a mixed scaling issue.)

So it looks like this is likely related to that one, and I'll make an account and post there later.  I'm hopeful that providing an easy-to-see test case will help.
Comment 16 Nate Graham 2025-02-08 01:07:27 UTC
Definitely sounds like an example of https://bugreports.qt.io/browse/QTBUG-128874!