Don't set wxTextAttr font family to invalid value.
wxTextAttr::HasFontFamily() shouldn't return true if there is no valid font family in this attribute but this could happen if it was constructed from a font which didn't know its own family. This fixes asserts on the startup of the text sample in wxMSW due to passing wxFONTFAMILY_UNKNOWN to wxFont::SetFamily() when trying to use such invalid attribute later. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62720 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
8faed39597
commit
aa926768a9
@ -333,7 +333,7 @@ wxFont wxTextAttr::GetFont() const
|
||||
if (HasFontEncoding())
|
||||
encoding = GetFontEncoding();
|
||||
|
||||
int fontFamily = wxFONTFAMILY_DEFAULT;
|
||||
wxFontFamily fontFamily = wxFONTFAMILY_DEFAULT;
|
||||
if (HasFontFamily())
|
||||
fontFamily = GetFontFamily();
|
||||
|
||||
@ -366,7 +366,16 @@ bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags)
|
||||
m_fontEncoding = font.GetEncoding();
|
||||
|
||||
if (flags & wxTEXT_ATTR_FONT_FAMILY)
|
||||
m_fontFamily = font.GetFamily();
|
||||
{
|
||||
// wxFont might not know its family, avoid setting m_fontFamily to an
|
||||
// invalid value and rather pretend that we don't have any font family
|
||||
// information at all in this case
|
||||
const wxFontFamily fontFamily = font.GetFamily();
|
||||
if ( fontFamily == wxFONTFAMILY_UNKNOWN )
|
||||
flags &= ~wxTEXT_ATTR_FONT_FAMILY;
|
||||
else
|
||||
m_fontFamily = fontFamily;
|
||||
}
|
||||
|
||||
m_flags |= flags;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user