wxWidgets & ClearType Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
givemeaname
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Jun 11, 2008 9:35 am

wxWidgets & ClearType

Post by givemeaname »

Hello,

does someone know how i can disable the cleartype-effect for a MSW-wxWidgets program? i need to draw some fonts without the cleartype-effect.

i know that cleartype can be globally turned on/off in windows, but thats not an option.

does someone knows a solution for that problem?

thanks for your help!
frank_frl
Earned some good credits
Earned some good credits
Posts: 139
Joined: Sat Feb 18, 2006 1:41 pm
Location: Germany

Post by frank_frl »

There is a flag for wxFont, but I don't know if that works on MSW.

Code: Select all

enum
{
    // no special flags: font with default weight/slant/anti-aliasing
    wxFONTFLAG_DEFAULT          = 0,

    // slant flags (default: no slant)
    wxFONTFLAG_ITALIC           = 1 << 0,
    wxFONTFLAG_SLANT            = 1 << 1,

    // weight flags (default: medium)
    wxFONTFLAG_LIGHT            = 1 << 2,
    wxFONTFLAG_BOLD             = 1 << 3,

    // anti-aliasing flag: force on or off (default: the current system default)
    wxFONTFLAG_ANTIALIASED      = 1 << 4,
    wxFONTFLAG_NOT_ANTIALIASED  = 1 << 5,

    // underlined/strikethrough flags (default: no lines)
    wxFONTFLAG_UNDERLINED       = 1 << 6,
    wxFONTFLAG_STRIKETHROUGH    = 1 << 7,
};
WinXp SP3, OS X10.5.5; CodeLite, Dialog::Blocks, wxWidgets 2.8.10
givemeaname
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Jun 11, 2008 9:35 am

Post by givemeaname »

Thanks for your answer. I tried the flags but they dont seem to work.
I also found this function:

Code: Select all

wxFont::SetNoAntiAliasing(bool);
But it doesn't work neither.


Ive found another solution that might be helpful for others:
i develop a tool that draws text and graphics on a monochrome LC-Display. so i changed the depth of wxBitmap/wxMemoryDC to 1.
Now fonts are drawn without the aliasing effect.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

a few comments:
a) antialiasing fonts and cleartype are two different things

b) the wxFONTFLAG_ANTIALIASED etc. flags are dummies, they are not used anywhere in the wxWidgets sources

c) the desired effect can be achieved by manually changing the native font info (wxFont::GetNativeFontInfoDesc()) and setting it back (wxFont::SetNativeFontInfo()). If anyone is interested in details, ask again. Too lazy to explain now ;)
Use the source, Luke!
givemeaname
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Jun 11, 2008 9:35 am

Post by givemeaname »

Thanks for pointing that out. I will give it a try.
marksatterfield
Knows some wx things
Knows some wx things
Posts: 33
Joined: Fri Jun 30, 2017 12:34 pm

Re: wxWidgets & ClearType

Post by marksatterfield »

Did anyone actually post the explanation on how to do this?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxWidgets & ClearType

Post by doublemax »

The string you get from GetNativeFontInfoDesc() looks like this:

Code: Select all

"0;-24;0;0;0;400;0;0;0;1;0;0;3;32;Lucida Sans Unicode"
The 13th value, in this case "3" is the FontQuality.

Possible values are:

Code: Select all

 typedef  enum
 {
   DEFAULT_QUALITY = 0x00,
   DRAFT_QUALITY = 0x01,
   PROOF_QUALITY = 0x02,
   NONANTIALIASED_QUALITY = 0x03,
   ANTIALIASED_QUALITY = 0x04,
   CLEARTYPE_QUALITY = 0x05
 } FontQuality;
https://msdn.microsoft.com/en-us/library/cc250391.aspx

This works under Windows only.
Use the source, Luke!
marksatterfield
Knows some wx things
Knows some wx things
Posts: 33
Joined: Fri Jun 30, 2017 12:34 pm

Re: wxWidgets & ClearType

Post by marksatterfield »

Thanks! :)
ollydbg23
Super wx Problem Solver
Super wx Problem Solver
Posts: 438
Joined: Fri Dec 12, 2008 10:31 am

Re: wxWidgets & ClearType

Post by ollydbg23 »

doublemax wrote: Fri Oct 26, 2018 4:56 pm The string you get from GetNativeFontInfoDesc() looks like this:

Code: Select all

"0;-24;0;0;0;400;0;0;0;1;0;0;3;32;Lucida Sans Unicode"
The 13th value, in this case "3" is the FontQuality.

Possible values are:

Code: Select all

 typedef  enum
 {
   DEFAULT_QUALITY = 0x00,
   DRAFT_QUALITY = 0x01,
   PROOF_QUALITY = 0x02,
   NONANTIALIASED_QUALITY = 0x03,
   ANTIALIASED_QUALITY = 0x04,
   CLEARTYPE_QUALITY = 0x05
 } FontQuality;
https://msdn.microsoft.com/en-us/library/cc250391.aspx

This works under Windows only.

Hi, doublemax, first, thanks for the great answer.

With this answer, I can now enable the "smooth font" in the Code::Blocks with the legacy GDI font render inside the wxScintilla control. (also the font wx sample).

But please note that the index has changed from 13 to 14, which takes me several hours to find the reason. I have use the wx font sample to debug into the wx library.

See details here:
font rendering issue when using C::B under windows remote desktop
Post Reply