OstinD
September 17, 2024, 12:20pm
1
Issue:
My JUCE app crashes on Windows when trying to load a non-existent font. Specifically, when using:
g.setFont(juce::Font(juce::FontOptions("NonExistingFont", 19, 0)));
drawText(g, "Some Text", 0, 0, 100, 100, juce::Justification::top);
It hits an assertion at line 123 in juce_Font.cpp.
Then it crashes instead of falling back to a default font.
Tested with the GUI_APP_EXAMPLE template too.
It’s a big issue as the user may not have all the font installed on his system making the app crashing on some config.
Environment
• OS: Windows 11
• JUCE Version: 8.1 (develop branch)
Many thanks for devs who will check this out !!
1 Like
reuk
September 17, 2024, 3:09pm
2
Thanks, I’m able to reproduce the problem and have a fix on the way. I’ll update this thread once the fix is public.
2 Likes
reuk
September 18, 2024, 5:23pm
3
Thanks again. This fix is now available on the develop branch:
committed 02:44PM - 18 Sep 24 UTC
Previously, when attempting to create a font with a name different to
that of an… y font on the system, the returned typeface could be nullptr.
This could lead to crashes when attempting to use the typeface.
Now, if we fail to find a matching font using DirectWrite, we fall back
to the older LOGFONT and DC approach, which will generally locate a
usable typeface, though not necessarily an exact match.
The new behaviour more closely matches the behaviour of JUCE 7, which
would attempt to construct a DirectWrite typeface, but would fall back
to creating an HFONT on failure.
Edit: updated link
2 Likes