In other words: This line is run every time I open the plugin window.
My problem: The font gets corrupted, after opening the plugin window several times inside a DAW. By corrupted I mean that letters are missing and that I even get crashes inside the font routines. For example, it can crash inside “TTrueTypeFontDataHandler::GetGlyphData”
I found a solution to my problem. But I am not sure yet, why it works:
I solved my problem, by first clearing the font cache with a call to clearTypefaceCache():
So apparently, the font cache is kept, even if the plugin GUI window is destructed. When you open the plugin GUI window again, it is going to use the same font cache. But for some reason, this font cache gets corrupted over time. Clearing the cache every time, solves this.
Is this cache corruption a known problem? Or am I doing something wrong?
I only seem to get this on OSX. On Windows it works fine without clearing the typeface cache first.
I am on OSX 10.14.4 and JUCE 5.4.3 Build Date 22 Feb 2019.
Known issue, it happens in our app quite regularly. The exact cause or solution isn’t known. I’ve been trying to reproduce the problem in a minimal program, but so far have been failing.
We’ve tried for years to nail this one down, but it’s very hard to reproduce. I assume it’s a bug in the OSX font system but exactly what triggers it, and how we’d work around it is very hard to guess. We’ll get it one day!
Bringing this up again. I have exactly the same issue. It crashed on my AAX Plugin on macOS and iOS app but not on my macOS app (all from the same codebase but quite random where it crashed and when).
As the issue seems to be OS related and not easy to resolve (if at all), I would highly recommend to put a warning in the docs.
Same issue here.
I’m on macOS 13.3, JUCE v7.0.5 [68beb7482] and in my case Typeface::clearTypefaceCache() doesn’t solve the problem.
I solved removing CTFontManagerRegisterGraphicsFont from OSXTypeface.
I did some digging in to this a while ago and summed up some information here:
Pretty much I found that removing the static keyword or doing as you suggest here resolves the issue, but never found out why. I suspect MacOS is trying to do something clever and share font resources between processes and marking the typeface data as static will prevent it from accessing the data outside of the declaring process. Or something like that. Because Apple.