diff --git a/modules/juce_graphics/fonts/juce_Font.cpp b/modules/juce_graphics/fonts/juce_Font.cpp index b6553ed19e..59e07b3e13 100644 --- a/modules/juce_graphics/fonts/juce_Font.cpp +++ b/modules/juce_graphics/fonts/juce_Font.cpp @@ -105,6 +105,15 @@ public: const ScopedWriteLock slw (lock); + auto newFace = CachedFace { key, + ++counter, + juce_getTypefaceForFont != nullptr + ? juce_getTypefaceForFont (font) + : Font::getDefaultTypefaceForFont (font) }; + + if (newFace.typeface == nullptr) + return nullptr; + const auto replaceIter = std::min_element (faces.begin(), faces.end(), [] (const auto& a, const auto& b) @@ -114,13 +123,8 @@ public: jassert (replaceIter != faces.end()); auto& face = *replaceIter; - face = CachedFace { key, - ++counter, - juce_getTypefaceForFont != nullptr - ? juce_getTypefaceForFont (font) - : Font::getDefaultTypefaceForFont (font) }; - jassert (face.typeface != nullptr); // the look and feel must return a typeface! + face = std::move (newFace); if (defaultFace == nullptr && key == Key{}) defaultFace = face.typeface; @@ -206,10 +210,7 @@ public: const ScopedLock lock (mutex); if (typeface == nullptr) - { typeface = options.getTypeface() != nullptr ? options.getTypeface() : TypefaceCache::getInstance()->findTypefaceFor (f); - jassert (typeface != nullptr); - } return typeface; } diff --git a/modules/juce_graphics/fonts/juce_SimpleShapedText.cpp b/modules/juce_graphics/fonts/juce_SimpleShapedText.cpp index 0124a3b680..8206d11ea9 100644 --- a/modules/juce_graphics/fonts/juce_SimpleShapedText.cpp +++ b/modules/juce_graphics/fonts/juce_SimpleShapedText.cpp @@ -463,10 +463,7 @@ static std::vector lowLevelShape (const String& string, auto nativeFont = font.getNativeDetails().font; if (nativeFont == nullptr) - { - jassertfalse; return {}; - } hb_shape (nativeFont.get(), buffer.get(), features.data(), (unsigned int) features.size()); @@ -1090,7 +1087,9 @@ struct Shaper auto glyphsIt = shapedGlyphs.find (startFrom); - if (glyphsIt == shapedGlyphs.end()) + // The stored glyphs data can be empty if there are input codepoints for which we failed to + // resolve a valid Typeface::Ptr. + if (glyphsIt == shapedGlyphs.end() || glyphsIt->value.data->empty()) return {}; WrappedGlyphs result;