Shouldn't wxSTC::SetFont() actually change the font?

14 views
Skip to first unread message

Vadim Zeitlin

unread,
Oct 3, 2012, 9:25:07 AM10/3/12
to wx-dev
Hello,

I've just discovered, with some surprise, that wxStyledTextCtrl::SetFont()
doesn't seem to do anything. To change the default font you apparently need
to call StyleSetFont(wxSTC_STYLE_DEFAULT, font) as the stc sample does. I
wonder if SetFont() shouldn't be overridden to do this? And, also, while
we're at it, why does StyleSetFont() take a non-const font? There doesn't
seem to be any good reason for it and to the best of my knowledge the wxGTK
hack in it is unnecessary.

Or does anybody know better?
VZ

Vadim Zeitlin

unread,
Oct 3, 2012, 12:20:52 PM10/3/12
to wx-...@googlegroups.com
On Wed, 3 Oct 2012 15:25:07 +0200 I wrote:

Me> I've just discovered, with some surprise, that wxStyledTextCtrl::SetFont()
Me> doesn't seem to do anything. To change the default font you apparently need
Me> to call StyleSetFont(wxSTC_STYLE_DEFAULT, font) as the stc sample does.

Next discovery: changing wxSTC_STYLE_DEFAULT is not enough in general, you
need to also change the styles used by the lexer. Unfortunately I didn't
find any better way to do this than setting font size for *all* styles,
i.e. for 256 of them if you use SetStyleBits(8). I am far from being sure
that this is correct so I won't do it in SetFont() by default. I'd like to
know if anybody knows of a better way to do this though.

Regards,
VZ
Reply all
Reply to author
Forward
0 new messages