The MASM Forum

General => The Workshop => Windows API => Topic started by: jj2007 on September 22, 2022, 07:49:42 PM

Title: ClearType Antialiasing
Post by: jj2007 on September 22, 2022, 07:49:42 PM
While trying to be helpful to a known Sudoku developer, I stumbled over this oddity called ClearType Antialiasing (https://learn.microsoft.com/en-us/windows/win32/gdi/cleartype-antialiasing). It works, but attention... it does not what you expect.

Attached sources plus two executables:
- one sets antialiasing off, as shown to the left of the image
- the other one sets antialiasing on, as shown to the right

Note the following:
- SystemParametersInfo does not only provide infos, it can also set parameters (the name is misleading)
- if used as a setter, it affects the whole system (your Explorer and all your menus will look funny)
- the big fonts shown below don't care about the setting, absolutely no difference

The MakeFont (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1094) macro used in the source uses CreateFontIndirect.
MakeFont hProof, Quality:PROOF_QUALITY, Height:-32, Weight:FW_SEMIBOLD
MakeFont hProofCT, Quality:CLEARTYPE_QUALITY, "Lucida Console"
MakeFont hTimes, "Times New Roman", Height:-24, Weight:FW_THIN
MakeFont hArial, "Arial", Underline:TRUE, Italic:0
MakeFont hRussian, Quality:0, Underline:FALSE, Italic:TRUE, Weight:FW_SEMIBOLD
Title: Re: ClearType Antialiasing
Post by: NoCforMe on September 22, 2022, 07:55:16 PM
Very interesting, JJ. But what type of font is that sans serif one at the top? Is it TrueType? Maybe it's a type of font that can't be anti-aliased. (It looks suspiciously like Arial.)
Title: Re: ClearType Antialiasing
Post by: jj2007 on September 22, 2022, 10:22:38 PM
Quote from: NoCforMe on September 22, 2022, 07:55:16 PM
Very interesting, JJ. But what type of font is that sans serif one at the top? Is it TrueType? Maybe it's a type of font that can't be anti-aliased. (It looks suspiciously like Arial.)

Very good question. It's what you get when you don't specify a type face like "Arial" or "Tahoma". As soon as you specify a type face, the anti-aliasing starts, except for "Terminal" (the default console font) or "System32". If you choose "System" without the 32, the font remains small, i.e. the size argument gets ignored. Mysteries of Windows :cool:
Title: Re: ClearType Antialiasing
Post by: NoCforMe on September 23, 2022, 07:31:28 AM
Yes, somewhat a mystery. I do know that there are types of fonts (bitmap ones, f'rinstance) that cannot be antialiased. So far as I know, all TrueType fonts can be.

Looking at my installed fonts, there are only 3 types: raster (bitmap), TrueType and OpenType. Not sure what that last type is.

I'm pretty sure System and System32 are just bits of ancient history left over "for compatibility reasons", so not much of a mystery there. Legacy stuff.
Title: Re: ClearType Antialiasing
Post by: hutch-- on September 23, 2022, 08:37:06 AM
That is the deal, the difference between vector and bitmap fonts. I personally like the ancient FIXEDSYS font but with the last few versions of Windows, Consolas works fine and is clear enough. Even Windows tends to use Segoe UI for many things so the ancient bmp fonts are just legacy products.
Title: Re: ClearType Antialiasing
Post by: TimoVJL on September 23, 2022, 09:26:50 AM
Quote from: NoCforMe on September 23, 2022, 07:31:28 AM
I do know that there are types of fonts (bitmap ones, f'rinstance) that cannot be antialiased. So far as I know, all TrueType fonts can be.
Anti-Aliasing image improvement technique works for bitmaps, also raster fonts belongs that group ?
Title: Re: ClearType Antialiasing
Post by: NoCforMe on September 23, 2022, 09:37:16 AM
Raster fonts are bitmap fonts, by definition. And I don't believe that; how can you antialias a bitmap font?

Hutch: I've come to like Segoe very much. It's much more readable, and just plain pleasant, than any of the previous Microsoft-official fonts. They chose well, I think.
Title: Re: ClearType Antialiasing
Post by: jj2007 on September 23, 2022, 09:44:45 AM
Quote from: jj2007 on September 22, 2022, 10:22:38 PMAs soon as you specify a type face, the anti-aliasing starts, except for "Terminal" (the default console font) or "System32". If you choose "System" without the 32, the font remains small, i.e. the size argument gets ignored.

Same for FixedSys (remains small, no anti-aliasing) and FixedSys32 (honours size arguments, has aa).

If a font does not exist, Windows tries to match the request with a similar one. Apparently, System and FixedSys don't have a match.