Here you go:
Ok - so renaming the fonts fixed it.
To rename the fonts I did this (on the mac using homebrew):
- brew install fonttools
- ttx Font.ttf
- Edit the ttx XML file to rename every instance of the fonts original name
- rm Font.ttf
- ttx Font.ttx
This certainly looks like a bug on our side, but Iām not having much luck reproducing it. Iāve tried installing the Rubik font, and then also including it as a binary resource and calling Typeface::createSystemTypefaceFor
for each of the embedded font styles. Then, Iāve tried setting a new default LookAndFeel in both the DemoRunner and a custom plugin project, and setting the default typeface to one of the embedded Rubik variants. So far, nothing Iāve tried has produced the garbled-looking text from the screenshots. My suspicion is that JUCE is applying attributes from an embedded font to a different font loaded from the filesystem (or vice versa), but without being able to reproduce the problem itās difficult to work out where that might be happening - or if itās happening at all!
Do you see the same results with all renderers (CoreGraphics, Software, OpenGL), or only with specific renderers? Also, do you see different results in plugins to standalones?
I couldnāt trivally replicate it either.
One of my guys suggested that it might occur if you have multiple look and feel classes in a project. We have some UI classes which have their own look and feel - e.g. custom knobs. Possibly it confuses the hell out of some font cache somewhere ā¦ ?
Thatās interesting. Do you have a program where you can consistently reproduce the issue? If so, could you try disabling additional LnF instances and check whether that fixes the issue?
(In case itās not clear, Iām not suggesting that this is a solution to the problem, but it could be a useful data point to try and narrow down where the problem is coming from.)
Iāll add some instances to my test program Probably easier!
Thatād be great. Have you tested with different renderers? Iād be interested to know whether you can reproduce the issue with both the Software renderer and the CoreGraphics renderer.
Whereās the magic switch to swap renderers?
Although presumably setFont only ever accesses the default look and feel? Because this is the only call to it:
static Typeface::Ptr getTypefaceForFontFromLookAndFeel (const Font& font)
{
return LookAndFeel::getDefaultLookAndFeel().getTypefaceForFont (font);
}
Yes, I donāt see any other uses of that function, so I think the multiple LnF theory is a bit unlikely.
You can set the renderer like this:
if (auto* comp = getTopLevelComponent()) {
if (auto* peer = comp->getPeer()) {
const auto engines = peer->getAvailableRenderingEngines();
peer->setCurrentRenderingEngine (engines.indexOf ("Software Renderer"));
}
}
Alternatively you could create an OpenGLContext and call attachTo
to attach it to your main editor component.
Sorry to barge in, but I had similar issues in the past (garbled fonts or missing fonts) and while this could be totally unrelated, here are a couple of instances where the issues happened:
-
In a plugin build I was using Desktop::setDefaultLookAndFeel. I was calling it from the constructor of the AudioProcessorEditor and passing a member pointer. But the desktop class stores the pointer globally, so if I opened 2 instances of the plugin and then closed the second one, the pointer would get lost into oblivion
-
On Windows: Memory-based font not rendering properly on Windows - #7 by masshacker
-
The good olā fun of multithreaded programming: I was accessing the same font from 2 threads at the same time
Iām not sure whether this can help or not, just throwing the info out there.
Ah right, so we are using the OpenGLContext::attachTo setup on the mac. Disabling it results in the fonts rendering correctly. Iāll try my test program again
Aha, thatās very interesting! It sounds like something is broken in JUCEās own rendering code, in that case. Iāll try reproducing the issue with an OpenGL renderer.
If you canāt repro, check you PMs
Thanks for all your help in tracking this down. The issue should be resolved by this patch: