Fix setting the fonts for wxMSW wxTextCtrl with wxTE_RICH(2) style.

Using WM_SETFONT seemed to work with rich edit controls but in fact it
doesn't, it only changes the font used by the control initially apparently but
it can be reset later.

Use EM_SETCHARFORMAT which is more reliable.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64394 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-05-25 21:15:24 +00:00
parent b8ea299a7e
commit 81fb185e4f
2 changed files with 23 additions and 2 deletions

View File

@@ -2360,6 +2360,26 @@ bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
return true;
}
bool wxTextCtrl::SetFont(const wxFont& font)
{
if ( !wxTextCtrlBase::SetFont(font) )
return false;
if ( IsRich() )
{
// Using WM_SETFONT doesn't work reliably with rich edit controls: as
// an example, if we set a fixed width font for a richedit 4.1 control,
// it's used for the ASCII characters but inserting any non-ASCII ones
// switches the font to a proportional one, whether it's done
// programmatically or not. So just use EM_SETCHARFORMAT for this too.
wxTextAttr attr;
attr.SetFont(font);
SetDefaultStyle(attr);
}
return true;
}
// ----------------------------------------------------------------------------
// styling support for rich edit controls
// ----------------------------------------------------------------------------