Garbled Fonts - Mac

We have some users who get an issue with garbled fonts. We have embedded the font in the app.

The users who have the issue also have the same font installed on their computer. When they remove it from their computer the problem goes away.

This affects multiple MacOS versions.

Anyone got any clues?

[I have noticed in one of our other plugins previously that if a dialog box appears before default LookAndFeel is set up and the typeface returned for a specific font changes this problem occurs. So maybe that’s a clue… but I think we are setting up the LookAndFeel pretty early in the app with the problem]

1 Like

Are you able to check if they have the font installed and if so use that rather than your in-memory version?

We see this occasionally too but I don’t know how to trigger it and I wasn’t aware of the above pattern.
Come to think of it, I’ve not seen this since I got a new machine and probably don’t have the font installed on it so maybe that was the cause :thinking:

1 Like

Ah - that is a good backup plan.

I’ve jsut found Typeface::clearTypefaceCache() so I’m going to try that directly after setting default look and feel first!

I think we do that already. It might have helped a bit…

“Helped a bit” :). Love these kinds of problems :slight_smile:

We have a bunch of customers who can repeat it every time. So I’ll pop this in the build and see if it fixes it for any of them.

I also moved room to one with more sunlight. It might have been that which helped. :wink:

1 Like

Oh, absolutely.
I also noticed that those pesky bugs thrive in the dark and hate sunlight :grinning_face_with_smiling_eyes:

What is your Typeface::Ptr getTypefaceForFont(const Font& font) implementation?

Typeface::Ptr LcLookAndFeel::getTypefaceForFont(const Font&f)
{
	if (f.getTypefaceName() == "OriginalSystem")
		return LookAndFeel_V3::getTypefaceForFont(Font());
    
    if (f.getTypefaceName() == "Monserrat-Regular")
        return monserrat->regular;
    
    if (f.getTypefaceName() == "Monserrat-Medium")
        return monserrat->medium;

	if (f.getTypefaceName() == "Monserrat-Semibold")
		return monserrat->semibold;

	if (f.getTypefaceName() == "Monserrat-Bold")
        return monserrat->bold;

    if (f.getTypefaceName() == "<Sans-Serif>")
    {
        Font font (f);
#ifdef JUCE_MAC
        font.setTypefaceName ("Helvetica Neue");
#else
        font.setTypefaceName ("Arial");
#endif
        return Typeface::createSystemTypefaceFor(font);
    }

    return LookAndFeel_V3::getTypefaceForFont(f);

}

Recently, I ran into garbled embedded fonts on macOS. I had an implementation logic similar to yours. Somehow, I found out the returned embedded typeface had to be consistent with the requested Font.

if (f.getTypefaceName() == "Montserrat" && f.getTypefaceStyle() == "Regular")
    return montserrat->regular;

I supposed you’re using Google’s Montserrat font (with an extra T :wink: )

Oh good spot! I’ve probably spelt that about 15 different ways so far :slight_smile:

Usually I called it Monster Rat :slight_smile:

:laughing:

Let me know how it goes.