About fonts

Hi,

Currently the font system is quite different between Windows and Mac.
I wonder how Juce users are displaying custom fonts in a cross platform way.

So far at UVI, we have been using Vinnie Falcon FreeType engine and it works great.
https://github.com/vinniefalco/VFLib/tree/master/modules/vf_freetype

At the time we used that because there was no Typeface::createSystemTypefaceFor so this was the only solution besides serialising font on the system which was clearly not very practical (even though we first started doing that in first Juce based products).

In some recent project, we have tried to move to Juce own stuff (createSystemTypefaceFor)
but it has some quirks.

On Windows, there was some user reporting some bogus font display which was fixed using TextLayout instead of Graphics::drawText (don’t ask me why)
On Mac, I have some alignement issue (centred is not really vertically centred)
And there is a huge difference in font size between OSX and Windows and probably rendering as well.

I wonder as well if the Juce Team has something planned for those shortcomings ?

Some reference of the issues

Thanks !

4 Likes

I find that fonts are displayed much bolder on mac than on Windows and that they can appear larger on mac.

To get around this, I simply use a lighter font on mac, loaded from binary data, and I scale the font size down by a fixed amount. Something like this:

Font getCustomFont(float height = 15.f)
{
#if JUCE_WINDOWS
    return customFontRegular.withHeight(height);
#else
    return customFontLight.withHeight(height * 0.8f);
}

For bolder font (not height), you can try JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING

The bolder font on macOS from what I remember is a difference between the font smoothing in CoreGraphics and whatever is used on windows. If I remember correctly using the OpenGLContext will be different again but consistent between platforms. Also I think if you draw the text into an image and then display the image it will also be different? It’s been a while since i investigated it and things may have changed since then though.

Now that juce6 has been released. Is there a plan to address those issue ?
Especially this one

Thanks !

3 Likes

\o/

I now understand why custom font have different size and placement on OSX and Window.

It’s all related to differences with HHead Ascent and HHead Descent (used by OSX) with Win Ascent and Win Descent (used by windows) in the font itself

More info here
font height differences

This can be fixed using FontForge
https://fontforge.org/

5 Likes

I’m struggling with this right now, the above link doesn’t work anymore, but presumably it was to this:

font Height

I followed the instructions using fontForge, but in the font I used the values were already the same for height in both win assent & HHead Ascent. I generated a TTF, but it’s still not right, the Windows rendering looks like letraset compared to the nice looking MAC rendering. The size actually looks the same, it’s more that the MAC version is much bolder.

Ahhh I see, the bold problem is separate issue, I’ll give this a try.