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

Font: Avoid a crash on systems with no fonts installed

This commit is contained in:
Tom Poole 2024-10-15 12:12:21 +01:00
parent 5453192a0c
commit 0f3bad8152

View file

@ -765,8 +765,13 @@ int Font::getStringWidth (const String& text) const
float Font::getStringWidthFloat (const String& text) const
{
const auto w = getTypefacePtr()->getStringWidth (getMetricsKind(), text, getHeight(), getHorizontalScale());
return w + (getHeight() * getHorizontalScale() * getExtraKerningFactor() * (float) text.length());
if (auto typeface = getTypefacePtr())
{
const auto w = typeface->getStringWidth (getMetricsKind(), text, getHeight(), getHorizontalScale());
return w + (getHeight() * getHorizontalScale() * getExtraKerningFactor() * (float) text.length());
}
return 0;
}
void Font::findFonts (Array<Font>& destArray)