[BR] No fallback font selected on Windows when using an embedded font

We’re embedding a TTF font file in our app using the JUCE binary data mechanism. The font only includes glyphs for latin and cyrilic languages, and so for langauges like Chinese, Korean, and Japanese we were relying on a fallback font being implicitly chosen.

On macOS this works as expected.

On Windows however, the text was completely blank - not even the placeholder [] characters were shown.

If we instead installed the font to the system, and used the juce::Font {"MyFont"} constructor, we had the expected behaviour where a fallback font was used for any glyphs that aren’t included in the specified font. However we don’t want to rely on the user having the font isntalled on their system - we want to be able to use an embedded font.

The returned result from juce::translate() is populated, so it’s something to do with the drawing of that text. We’re drawing the text using a juce::AttributedString.

I’ll try to find time to put together a PIP to reproduce the bug, but it should be as simple as using an embedded font and then trying to display a glyph on Windows that’s not included in that font.

1 Like

use TextLayout and set JUCE_USE_DIRECTWRITE to 1

Ahh, I’d missed that AttributedString doesn’t use TextLayout by default… I thought it did! That’s probably something to try then, thanks @otristan!

For now we’ve worked around this by simply embedding extra fonts for the different langauges we’re supporting - which in hindsight is what we should be doing anyway and not relying on some unknown fallback font.

This still appears to be a bug with JUCE though - especially as the behaviour is different between macOS and Windows, and AFAIK there’s no documentation to say whether or not what we’re doing is wrong.