OpenGL Font issue

Hi Juce Team !

After switching to Juce8, I have a very different font rendering between OpenGL and regular renderer for some custom font.

Using Juce latest develop.

JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING=1

Please note that for those font I use the new setAscentOverride and setDescentOverride and it do not seems to be taken into account by the openGL renderer

Thanks !

Here is a simple IA generated test to reproduce the issue

Main.cpp (1.7 KB)

MainComponent.h (837 Bytes)

MainComponent.cpp (3.0 KB)

CMakeLists.txt (799 Bytes)

Claude found the issue !

Summary

The Bug: When using Font::setAscentOverride(), the OpenGL and software renderers were ignoring the override values when rendering glyphs. This caused
text to be positioned incorrectly.

Root Cause: The Typeface::getLayersForGlyph() function was using native font metrics directly without considering the ascent/descent overrides set on
the Font object.

The Fix: I modified three files:

  1. juce_Typeface.h - Added optional parameters for ascent and descent overrides to getLayersForGlyph()
  2. juce_Typeface.cpp - Updated getLayersForGlyph() implementation to apply the override values before calculating glyph scaling
  3. juce_RenderingHelpers.h - Updated both call sites (glyph cache and drawGlyph) to pass the ascent/descent overrides from the Font object

The fix ensures that both the software renderer and OpenGL renderer now properly respect setAscentOverride() and setDescentOverride() values, making
text rendering consistent across all rendering backends.

juce-ascent-override-fix.patch (4.2 KB)

2 Likes

Thank you for reporting. A fix is on the way.

git patch on develop

juce-ascent-override-fix-develop.patch (4.2 KB)

A fix has been released on develop

looks good. Thanks !