# Problems with fonts on MacOS since updating to JUCE7

**URL:** <https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835>\
**Category:** General JUCE discussion\
**Created:** [August 31, 2022, 3:43pm UTC](https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835 "2022-08-31T15:43:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![icebreakeraudio](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/icebreakeraudio/32/10446_2.png) [@icebreakeraudio](https://forum.juce.com/u/icebreakeraudio)\
**Post date:** [August 31, 2022, 3:43pm UTC](https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835/1 "2022-08-31T15:43:48Z")

</div>

Hello all,  
I’ve been having difficulty recently with labels displaying garbled text (see image)  
 ![Screenshot 2022-08-31 161845](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/a/a9d209303adc649e42e98fe88fa129acc41a555a.png)  
I’ve been using a custom lookAndFeel that overrides getTypefaceForFont like this:

```auto
  juce::Typeface::Ptr getTypefaceForFont(const juce::Font& font) override
  {
      auto name = font.getTypefaceName();
      auto isBold = font.isBold();
      if(name.compare("tall") == 0)
      {
          return condensedFont;
      }
      else if (isBold)
      {
          return boldFont;
      }
      else
      {
          return defaultFont;
      }
  }

```

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.

---

<div class="post-metadata">

**Author:** ![icebreakeraudio](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/icebreakeraudio/32/10446_2.png) [@icebreakeraudio](https://forum.juce.com/u/icebreakeraudio)\
**Post date:** [August 31, 2022, 3:55pm UTC](https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835/2 "2022-08-31T15:55:54Z")

</div>

Seems I’m not the first with this problem… but not sure how disabling carbon would help with the windows build?  
I’m also not sure why JUCE7 made it so much worse.

> [@Garbled text on macOS](https://forum.juce.com/t/garbled-text-on-macos/21594):
>
> Hi, one user of an application of mine has a strange problem where (most) of the text in dialogs is completely garbled: macOS sierra 10.12.3, English It seems that every letter is replaced with some other letter. The top two labels are “Network Name:” and “Network Port:”. The bottom buttons are “OK” and “Cancel”. It happens with the old version of our app (from 2013 or so), but also with a rebuild with JUCE from GitHub from March 5, 2017. I have neither been able to reproduce the pr…

---

<div class="post-metadata">

**Author:** ![Fandusss](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@Fandusss](https://forum.juce.com/u/Fandusss)\
**Post date:** [August 31, 2022, 3:58pm UTC](https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835/3 "2022-08-31T15:58:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![icebreakeraudio](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/icebreakeraudio/32/10446_2.png) [@icebreakeraudio](https://forum.juce.com/u/icebreakeraudio)\
**Post date:** [August 31, 2022, 4:02pm UTC](https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835/4 "2022-08-31T16:02:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Fandusss](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@Fandusss](https://forum.juce.com/u/Fandusss)\
**Post date:** [August 31, 2022, 4:16pm UTC](https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835/5 "2022-08-31T16:16:32Z")

</div>

In editor.h I had this. You can try it real quick. Not sure if it’s the same issue but good luck.

```auto

struct DefaultLookAndFeel
    {
        DefaultLookAndFeel()
        {
            juce::LookAndFeel::setDefaultLookAndFeel(&lnf);
            static auto font = juce::Typeface::createSystemTypefaceFor(BinaryData::RobotoRegular_ttf, BinaryData::RobotoRegular_ttfSize);
            lnf.setDefaultSansSerifTypeface(font);
        }

        ~DefaultLookAndFeel()
        {
            juce::LookAndFeel::setDefaultLookAndFeel(nullptr);
        }

        MyLookAndFeel lnf;

    };

    juce::SharedResourcePointer<DefaultLookAndFeel> defaultLnf;

```

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [August 31, 2022, 5:08pm UTC](https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835/6 "2022-08-31T17:08:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![icebreakeraudio](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/icebreakeraudio/32/10446_2.png) [@icebreakeraudio](https://forum.juce.com/u/icebreakeraudio)\
**Post date:** [August 31, 2022, 5:43pm UTC](https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835/7 "2022-08-31T17:43:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [August 31, 2022, 6:28pm UTC](https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835/8 "2022-08-31T18:28:54Z")

</div>

> [@icebreakeraudio](#):
>
> Is there a way to share these things privately?

You could send the project in a direct message to me as a .zip, or add me as a collaborator on a private repo on github (my handle is @reuk there too).

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [August 31, 2022, 6:35pm UTC](https://forum.juce.com/t/problems-with-fonts-on-macos-since-updating-to-juce7/52835/9 "2022-08-31T18:35:58Z")

</div>

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.
