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:
parent
5453192a0c
commit
0f3bad8152
1 changed files with 7 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue