It's not impossible for the font face to fail loading
LoadFont()'s only usage already checked for nullptr to fallback, let's actually return nullptr on a failed load
Fixes sentry KICAD-8Z
Make the cause of sentry KICAD-95
(cherry picked from commit e8e407dfba
)
This commit is contained in:
parent
7a2a51ad44
commit
a48eace90a
|
@ -90,26 +90,29 @@ wxString OUTLINE_FONT::FontLibraryVersion()
|
||||||
|
|
||||||
OUTLINE_FONT* OUTLINE_FONT::LoadFont( const wxString& aFontName, bool aBold, bool aItalic )
|
OUTLINE_FONT* OUTLINE_FONT::LoadFont( const wxString& aFontName, bool aBold, bool aItalic )
|
||||||
{
|
{
|
||||||
OUTLINE_FONT* font = new OUTLINE_FONT();
|
std::unique_ptr<OUTLINE_FONT> font = std::make_unique<OUTLINE_FONT>();
|
||||||
|
|
||||||
wxString fontFile;
|
wxString fontFile;
|
||||||
using fc = fontconfig::FONTCONFIG;
|
using fc = fontconfig::FONTCONFIG;
|
||||||
|
|
||||||
fc::FF_RESULT retval = Fontconfig()->FindFont( aFontName, fontFile, aBold, aItalic );
|
fc::FF_RESULT retval = Fontconfig()->FindFont( aFontName, fontFile, aBold, aItalic );
|
||||||
|
|
||||||
|
if( retval == fc::FF_RESULT::FF_ERROR )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
if( retval == fc::FF_RESULT::FF_MISSING_BOLD || retval == fc::FF_RESULT::FF_MISSING_BOLD_ITAL )
|
if( retval == fc::FF_RESULT::FF_MISSING_BOLD || retval == fc::FF_RESULT::FF_MISSING_BOLD_ITAL )
|
||||||
font->SetFakeBold();
|
font->SetFakeBold();
|
||||||
|
|
||||||
if( retval == fc::FF_RESULT::FF_MISSING_ITAL || retval == fc::FF_RESULT::FF_MISSING_BOLD_ITAL )
|
if( retval == fc::FF_RESULT::FF_MISSING_ITAL || retval == fc::FF_RESULT::FF_MISSING_BOLD_ITAL )
|
||||||
font->SetFakeItal();
|
font->SetFakeItal();
|
||||||
|
|
||||||
if( retval != fc::FF_RESULT::FF_ERROR )
|
if( font->loadFace( fontFile ) != 0 )
|
||||||
(void) font->loadFace( fontFile );
|
return nullptr;
|
||||||
|
|
||||||
font->m_fontName = aFontName; // Keep asked-for name, even if we substituted.
|
font->m_fontName = aFontName; // Keep asked-for name, even if we substituted.
|
||||||
font->m_fontFileName = fontFile;
|
font->m_fontFileName = fontFile;
|
||||||
|
|
||||||
return font;
|
return font.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue