Make wxStyledTextCtrl fonts Smooth

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Make wxStyledTextCtrl fonts Smooth

Post by evstevemd » Wed Feb 13, 2019 5:15 am

How can I make fonts in wxStyledTextCtrl as smooth as other editors (Like Sublime Text or VSCode)? Here are the two screenshots one of my app and another for VSCode. Obviously mine isn't as smooth as VSCode (both opening same file, font size being 14). Checking wxFontInfo I see:

Code: Select all

wxFontInfo& wxFontInfo::AntiAliased(bool  antiAliased = true) 	
Set anti-aliasing flag. Force the use of anti-aliasing on or off.
Currently this is not implemented, i.e. using this method doesn't do anything.
Since I guess the font in VSCode is antialised (I stand to be corrected), then how do we achieve the same with wxWidgets?


Mine
mine.png
mine.png (20.11 KiB) Viewed 106 times
One from VSCode
vscode.png
vscode.png (25.21 KiB) Viewed 106 times
My Editor have a lot of code but the part I think is relevant is:

Code: Select all

wxFont font(wxFontInfo(faceSize).FaceName(faceName));
m_stc->SetFont(font);
TIA
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

PB
Part Of The Furniture
Part Of The Furniture
Posts: 1837
Joined: Sun Jan 03, 2010 5:45 pm

Re: Make wxStyledTextCtrl fonts Smooth

Post by PB » Wed Feb 13, 2019 6:23 am

Assuming you are using wxWidgets 3.1.1+ on MSW, have you tried SetFontQuality() with SetTechnology(wxSTC_TECHNOLOGY_DIRECTWRITE)? See this commit
https://github.com/wxWidgets/wxWidgets/ ... ad9647da0a

User avatar
doublemax
Moderator
Moderator
Posts: 13003
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Make wxStyledTextCtrl fonts Smooth

Post by doublemax » Wed Feb 13, 2019 6:26 am

Your version is definitely anti-aliased.
fontszoomed.png
fontszoomed.png (11.58 KiB) Viewed 93 times
Use the source, Luke!

User avatar
doublemax
Moderator
Moderator
Posts: 13003
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Make wxStyledTextCtrl fonts Smooth

Post by doublemax » Wed Feb 13, 2019 6:32 am

There is a method to enable ClearType under Windows using wxFont::Get/Set NativeFontInfoDesc()
viewtopic.php?f=23&t=21733

Maybe try that and check if it looks better to you.
Use the source, Luke!

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Make wxStyledTextCtrl fonts Smooth

Post by evstevemd » Wed Feb 13, 2019 6:35 am

PB wrote:Assuming you are using wxWidgets 3.1.1+ on MSW, have you tried SetFontQuality() with SetTechnology(wxSTC_TECHNOLOGY_DIRECTWRITE)? See this commit
https://github.com/wxWidgets/wxWidgets/ ... ad9647da0a
I currently develop on Mac. But will setup on Windows and test that.
The app is cross platform.
Thank you.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Make wxStyledTextCtrl fonts Smooth

Post by evstevemd » Wed Feb 13, 2019 6:37 am

doublemax wrote:Your version is definitely anti-aliased.
fontszoomed.png
:D :D :D
So what might be making the difference?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Make wxStyledTextCtrl fonts Smooth

Post by evstevemd » Wed Feb 13, 2019 6:37 am

doublemax wrote:There is a method to enable ClearType under Windows using wxFont::Get/Set NativeFontInfoDesc()
viewtopic.php?f=23&t=21733

Maybe try that and check if it looks better to you.
Thank you. I will definitely try that!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
doublemax
Moderator
Moderator
Posts: 13003
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Make wxStyledTextCtrl fonts Smooth

Post by doublemax » Wed Feb 13, 2019 6:42 am

So what might be making the difference?
The font weight of the VS version just looks a tiny bit higher. But VS is Chrome based, maybe Chrome has its own font rendering engine.
Use the source, Luke!

PB
Part Of The Furniture
Part Of The Furniture
Posts: 1837
Joined: Sun Jan 03, 2010 5:45 pm

Re: Make wxStyledTextCtrl fonts Smooth

Post by PB » Wed Feb 13, 2019 6:46 am

As doublemax said, VSCode is an Electron app, so all its UI is rendered by a web browser (chromium).

How do other Scintilla-based applications look, e.g. SciTe and Notepad++?

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Make wxStyledTextCtrl fonts Smooth

Post by evstevemd » Wed Feb 13, 2019 6:51 am

doublemax wrote:The font weight of the VS version just looks a tiny bit higher
I saw that and though may be its bold. But then I found in settings its regular.
doublemax wrote:But VS is Chrome based, maybe Chrome has its own font rendering engine.
It might be. but even sublime text looks the same (see the screenshot).
So I believe somemthing is missing in wxWidgets. The problem is I don't know what it is :)
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Make wxStyledTextCtrl fonts Smooth

Post by evstevemd » Wed Feb 13, 2019 6:59 am

PB wrote:As doublemax said, VSCode is an Electron app, so all its UI is rendered by a web browser (chromium).
I see!
PB wrote:How do other Scintilla-based applications look, e.g. SciTe and Notepad++?
Not so different from mine. I checked Notepad++, Komodo Edit, Zerobrane, and CodeLite.

Here is a screenshot of the same font and size in CodeLite (One of the best Scintilla based app)
codelite.png
codelite.png (19.42 KiB) Viewed 69 times
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2104
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Make wxStyledTextCtrl fonts Smooth

Post by evstevemd » Wed Feb 13, 2019 7:01 am

I think it is wxWidgets limitations. I will apply your suggestions on Windows and see what I get.
Meanwhile if anyone knows anything helpful for Mac/Gtk, I would appreciate that!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

PB
Part Of The Furniture
Part Of The Furniture
Posts: 1837
Joined: Sun Jan 03, 2010 5:45 pm

Re: Make wxStyledTextCtrl fonts Smooth

Post by PB » Wed Feb 13, 2019 7:01 am

evstevemd wrote:but even sublime text looks the same (see the screenshot).
So I believe somemthing is missing in wxWidgets.
Is sublimetext using Scintilla? I think one would need to compare scintilla-based editors to make sure the issue is with wxWidgets (Scintilla wrapper)...

User avatar
doublemax
Moderator
Moderator
Posts: 13003
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Make wxStyledTextCtrl fonts Smooth

Post by doublemax » Wed Feb 13, 2019 7:02 am

I saw that and though may be its bold. But then I found in settings its regular.
Try slightly higher fontweight ("boldness") settings through wxFont::SetNumericWeight(). 400 is normal, 700 is bold.

https://htmldog.com/references/css/prop ... nt-weight/
Use the source, Luke!

PB
Part Of The Furniture
Part Of The Furniture
Posts: 1837
Joined: Sun Jan 03, 2010 5:45 pm

Re: Make wxStyledTextCtrl fonts Smooth

Post by PB » Wed Feb 13, 2019 7:08 am

evstevemd wrote:Here is a screenshot of the same font and size in CodeLite (One of the best Scintilla based app)
So CodeLite looks OK?

CodeLite uses wxWidgets for its UI and I believe it also uses its wxSTC as I remember eranif commenting on its issues including the one resulting in the commit referenced in my first post in this thread...

Post Reply