mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
Fix crash when no valid Typeface::Ptr can be resolved
This commit is contained in:
parent
8be78e9f7f
commit
ba61c9edb9
2 changed files with 13 additions and 13 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -463,10 +463,7 @@ static std::vector<ShapedGlyph> 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue