diff --git a/interface/wx/dcgraph.h b/interface/wx/dcgraph.h index 045661afc9..c60a00e7e0 100644 --- a/interface/wx/dcgraph.h +++ b/interface/wx/dcgraph.h @@ -10,6 +10,10 @@ wxGCDC is a device context that draws on a wxGraphicsContext. + @remarks + If Direct2D is a renderer of underlying graphics context, only wxFont objects + representing TrueType fonts can be used in the font-related functions. + @library{wxcore} @category{dc} diff --git a/src/common/graphcmn.cpp b/src/common/graphcmn.cpp index 60dbf25885..bdf0597149 100644 --- a/src/common/graphcmn.cpp +++ b/src/common/graphcmn.cpp @@ -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 )