1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Fall back to default sans serif font if resolution would fail otherwise

This restores the JUCE 7 behaviour when the JUCE 8 font fallback
mechanism fails to resolve a non-null Typeface::Ptr. This behaviour is
significant when the base font specified is not available on the system.
This commit is contained in:
attila 2025-01-07 17:22:27 +01:00
parent ba61c9edb9
commit d73b1768a7

View file

@ -836,9 +836,19 @@ Font Font::findSuitableFontForText (const String& text, const String& language)
return copy;
}
if (auto current = getTypefacePtr())
const auto fallbackTypefacePtr = std::invoke ([&]
{
if (auto suggested = current->createSystemFallback (text, language))
if (auto current = getTypefacePtr())
return current;
auto copy = *this;
copy.setTypefaceName (Font::getDefaultSansSerifFontName());
return copy.getTypefacePtr();
});
if (fallbackTypefacePtr != nullptr)
{
if (auto suggested = fallbackTypefacePtr->createSystemFallback (text, language))
{
auto copy = *this;