Check for valid font in wxTextMeasure before using it
It turns out that wxEnhMetaFileDC doesn't have any valid font in wxMSW,
so the changes of 70768a33d2
(Dramatically speed up measuring text
extent in wxMSW, 2020-06-10) broke its GetTextExtent().
Fix this by checking if we have a valid font explicitly, although
perhaps a better fix would be to ensure that wxEnhMetaFileDC also always
has a default font, as the other wxDC classes.
This commit is contained in:
@@ -113,7 +113,8 @@ void wxTextMeasure::DoGetTextExtent(const wxString& string,
|
||||
// and calling GetCharABCWidths() is pretty slow and much slower than
|
||||
// calling GetTextExtentPoint32() itself, so avoid its overhead unless it's
|
||||
// really, really necessary).
|
||||
if ( GetFont().GetStyle() != wxFONTSTYLE_NORMAL && len > 0 )
|
||||
const wxFont font = GetFont();
|
||||
if ( font.IsOk() && font.GetStyle() != wxFONTSTYLE_NORMAL && len > 0 )
|
||||
{
|
||||
ABC widthABC;
|
||||
const wxChar chFirst = *string.begin();
|
||||
|
Reference in New Issue
Block a user