Change current font only if new graphics font is successfully created

If new graphics font couldn't be created successfully there is no need
to reset current font by updating it to wxNullGraphicsFont.

Closes #17790.
This commit is contained in:
Artur Wieczorek
2017-04-17 18:32:31 +02:00
parent 7f9453dfdf
commit 06963940fb
2 changed files with 15 additions and 2 deletions

View File

@@ -653,12 +653,21 @@ void wxGraphicsContext::SetFont( const wxGraphicsFont& font )
m_font = font;
}
void wxGraphicsContext::SetFont( const wxFont& font, const wxColour& colour )
void wxGraphicsContext::SetFont(const wxFont& font, const wxColour& colour)
{
if ( font.IsOk() )
SetFont( CreateFont( font, colour ) );
{
// Change current font only if new graphics font is successfully created.
wxGraphicsFont grFont = CreateFont(font, colour);
if ( !grFont.IsSameAs(wxNullGraphicsFont) )
{
SetFont(grFont);
}
}
else
{
SetFont( wxNullGraphicsFont );
}
}
void wxGraphicsContext::DrawPath( const wxGraphicsPath& path, wxPolygonFillMode fillStyle )