About fonts


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.

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 !


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)
    return customFontRegular.withHeight(height);
    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 !



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