Bug 497819 - Full hinting (byte code interpreter) for fonts does not work
Summary: Full hinting (byte code interpreter) for fonts does not work
Status: NEEDSINFO WAITINGFORINFO
Alias: None
Product: kde
Classification: I don't know
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-23 08:42 UTC by andrew
Modified: 2025-01-07 19:48 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

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!