Juce 8, new font system

Hi Guys,

I was checking Juce 8 today and I’m facing some issue

Right now, I use CustomTypeFace using TheVinn FreeType based font

I was wondering what would be the way to have something compatible with Juce 8 (with the new FontOptions ?)

Thanks !

Please can you explain your use-case? Are you only trying to get nicer hinting, or do you need other features like a custom mapping of glyph indices to paths/EdgeTables?

I suspect that there’s less need for manual hinting on the JUCE 8 branch, as glyphs are drawn through DirectWrite/Direct2D on Windows, and CoreText/CoreGraphics on macOS. These systems should hint appropriately.

We don’t have a good solution for hinting in the Software or OpenGL renderers at the moment, but we’ll consider it if there’s demand for this feature.

Unforunately I don’t think there is. JUCE 8 doesn’t currently have a customisation point for overriding the paths or EdgeTables for individual glyphs of a typeface.

The rationale was to have a similar font size and rendering between Mac and PC especially in custom TTF (direct from disk TTF support wasn’t available at the time in Juce moreover)
The hinting is not that mandatory especially with retina.

I will do tomorrow screenshot of differences.

I cannot clearly upgrade to Juce 8 if product UI won’t look the same.

Thanks !

You should find with the D2D renderer and changes to the way we read metrics from the font that fonts render much more similar between platforms than they used to.

There is still a considerable difference in thickness, to the point we have to use -100 on Mac, so it looks close enough on both.

Windows: “Figtree” 500
macOS: “Figtree” 400

Now both look very similar. If both are 500, the Mac version looks considerably thicker.

I even had to fudge the kerning on Windows by -0.04, because on Mac it looked a bit tighter, but better to my eyes.

1 Like

I did not try JUCE 8 on Mac so far, but with JUCE 7 I found that JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING did help a lot in keeping both systems closer.

First issue seems to be the centering using custom font

DIN.ttf (348.3 KB)

Not setting a custom font will result in a well centered text
Just a centered label with a red background color

Regarding the size, I have a factor between FreeType and Juce of 0.8 but this is maybe one of the shenanigan of Vinnie to match previous Juce system so I can live with that :slight_smile:

Here is the same centered label


with a much bigger size

Looks like the 0.8 factor and the centering issue is not that common but clearly happen with URWDIN-Regular

This happen as well with AvantGarGotItcTOT-Med.otf which is a URW font as well.

Happen as well with Acumin Pro
FontsFree-Net-Acumin-Pro-Light.ttf (111.5 KB)

JUCE 8 has a couple of different metrics options. The old ‘legacy’ option emulates the ascender/descender behaviour from JUCE 7. The disadvantage of this approach is that the ascender/descender for a given font may be reported differently depending on the platform. There’s also a new ‘portable’ option, which will always produce the same metrics values on all platforms for a given font.

The default metrics kind is ‘portable’ when constructing from a FontOptions, and ‘legacy’ when using the old Font constructors. I’d expect the portable metrics to behave slightly better. Which kind of metrics are you using for testing?

I tried with portable using FontOptions and made sure in the debugger it was using portable one

Thank you so much. This made a HUGE difference. Now you can barely tell they are different. The Windows version looks a tiny bit thicker, but I attribute that to gamma and glyph-interpretation differences between systems. At first glance, nobody will be able to tell the difference; only when overlaying both with Photoshop and switching back and forth can you (barely) tell. This is great. Thank you so much.

@reuk JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING should be enabled by default for the JUCE8 branch—or at least mentioned in the upgrading to juce8 manual—as this is a HUGE step forward in platform parity. With the new FontOptions object, Harfbuzz, and D2D, the font rendering between Windows and Mac is now nearly identical. If you disable the font smoothing by default, newcomers will have a much better time with JUCE.

4 Likes

Glad to hear this did solve your issue!
I agree that this should be the default behavior, and JUCE 8 is the perfect opportunity to do this breaking change.

1 Like

The issue here is more a centering issue on certain ttf font rather than a metric issue FWIW.

I would think that font is simply using extreme ascender/descender values. Maybe a new centering mode can be added, BASELINE, where the text gets vertically centered between ascender and the baseline property?

The same font was centered just fine when using a customTypeFace that was using FreeType
hence my idea this is a edge case not well handled

I cannot test in another toolkit like Qt see if this is well centered though

The problem I have is that, with the embedded font I use, I prefer the way it looks on Mac (with the default font smoothing). I’ve been putting up with the slightly thinner appearance on Windows.

I just tried JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING=1, and it makes it slightly thinner on the Mac - closer to Windows - but for me, that’s going the wrong way.

If I wanted to make the Windows version look more like the Mac, how would I thicken it slightly? I’m afraid I don’t know that much about fonts. When you talk about these weights of “500” and “400”, how do you apply this to a font in JUCE? Do you actually make a version of the font file that somehow has this value applied?

Just to make the question more clear:

How do you accomplish this in JUCE 7?