I’ve been having difficulty recently with labels displaying garbled text (see image)
I’ve been using a custom lookAndFeel that overrides getTypefaceForFont like this:
juce::Typeface::Ptr getTypefaceForFont(const juce::Font& font) override
auto name = font.getTypefaceName();
auto isBold = font.isBold();
if(name.compare("tall") == 0)
else if (isBold)
Where each of the returned typefaces are set as constants in the LookAndFeel class using: juce::Typeface::createSystemTypefaceFor()
I am then setting the lookAndFeel as the default lookAndFeel in the PluginEditor: juce::LookAndFeel::setDefaultLookAndFeel(&customLnF);
This all used to work fine in JUCE6, but since updating to JUCE7 the text gets messed up often and is very easy to reproduce in Logic when using multiple instances of the AU plugin. It’s more difficult to reproduce on Windows, but it has happened once or twice.
One of the main problems is that the main information for using custom fonts comes from very confused forums, and there seems to be no up-to-date official guide.
Has anybody encountered this issue before and solved it? I’m at a loss.
I’ll look over some old code tomorrow, because this sounds familiar. Does it happen after you close a gui? If you open 3 without closing any, are they all fine? Then when you close 1, the problem starts?
If so, I think I fixed this by wrapping the LnF and font in a sharedResourcePointer.
In the AU build the problem happens when I open a second instance seemingly regardless of any other factors. The original instance is fine, but the second one has garbled text.
On Windows it’s a bit more hit and miss, but seems to happen after the tooltip window appears.
In any case, the problem can be fixed by forcing a repaint by resizing the UI.
I haven’t looked into the sharedResourcePointer stuff, but I’ll check it out now.
This issue hasn’t been reported for at least a year now, so I thought it had been fixed. It would be extremely helpful if you could put together a small project that demonstrates the problem, along with some detailed steps to trigger the issue.
I’ll see if I can put something together for you, but it’s a pretty big project. I’ll see what I can cut out. Is there a way to share these things privately?
I can tell you now that it was reproduceable when using JUCE6, but rare. However it is now easy to reproduce on the Mac builds using JUCE7. I initially found it by loading multiple instances of the same plugin in Logic after updating to JUCE7.
Using the sharedResourcePointer seems to have fixed it on Windows ( thanks @Fandusss ). I’ll be testing on Mac tonight.
Make sure that you don’t put font in static struct.
Your font cache should be in something that uses DeleteAtShutdown otherwise font are messed when Juce is deleted but your DLL is still loaded and a new instance is loaded.