Assertion in FontOptions when switching to JUCE 8

Hi,

I keep on hitting this inexplicably hitting this assertion here:

    [[nodiscard]] FontOptions withTypeface (Typeface::Ptr x) const
    {
        // If the typeface is non-null, then the name and style fields will be ignored.
        jassert (x == nullptr || name.isEmpty()); //ASSERTS
        jassert (x == nullptr || style.isEmpty());

        auto result = (x != nullptr ? withName (x->getName()).withStyle (x->getStyle()) : *this);
        return withMember (std::move (result), &FontOptions::typeface, x);
    }

This is only after upgrading to juce 8. I have not modified any of the font code at all apart from this which has had no effect:

//any call to draw text first requires a call to g.setFont(font::get(h)); this is how i handle default fonts
namespace fonts {
static const juce::Typeface::Ptr getTypeface() {
    static const auto typeface = juce::Typeface::createSystemTypefaceFor (BinaryData::font_ttf, BinaryData::font_ttfSize);
    return typeface;
}
//this: static const juce::Font get(float h) {return juce::Font(getTypeface()).withHeight(h);}
//to this:
static const juce::Font get(float h) {return juce::Font(juce::FontOptions(getTypeface())).withHeight(h);}
}

Anyone know whats going on here?

Are you using the tagged 8.0.0 release, or the develop branch?

If you haven’t tried the develop branch yet, please test it and let us know whether the problem persists. I suspect the problem may already be resolved by this change:

1 Like

You got any unicode symbols in there? ♭♯ etc? I was getting this assert whenever the font didnt supoprt the unicode symbol searched for. I’ve been avoiding it by always having at least one fallback that covers all my symbols.

e.g.

chordNameFont = FontOptions{}.withName("Noto Sans").withStyle("SemiBold").withHeight(20).withFallbacks({ "Lucida Sans Unicode", "Noto Music" });

this indeed fixed it :man_facepalming: .
something strange happened my juce submodule but is fixed now by resyncing to the latest develope branch.

cheers