News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Ugly text on Windows 7

Started by NoCforMe, June 27, 2012, 01:59:14 PM

Previous topic - Next topic

NoCforMe

Problem is the way text renders on the screen.

I've got a few programs that use TextOut() to draw text on the display. Today I tried them on a computer running Windows 7 (with a large LCD display) and man, did they ever look ugly! Jagged, ragged characters. Not smooth at all.

To give some background, my machine is an antique running Windows 2000 (Pro), with a glass monitor (CRT), and all my text renders pretty much OK on it.

So first thing I did was up the quality of the fonts I was creating using CreateFont() by changing ANTIALIASED_QUALITY to CLEARTYPE_QUALITY. This had a noticeable positive effect, but some of the text was still quite jagged looking. In addition, one of my apps that writes text one character at a time using TextOut() showed considerable clipping and other fugliness of certain adjacent characters. Again, this doesn't happen on my machine.

I know this is potentially a deep, deep topic, possibly involving display characteristics, device drivers, Clear Type, etc., etc. I have a couple simple questions:

1. What is the difference, visual results-wise, between TextOut() and DrawText()/DrawTextEx()? Is one preferred over the other, at least on newer OSs like Windows 7? (I know there are functional differences, like being able to draw text within a rectangle with DrawText().)

2. Are the other quality parameters passed to CreateFont() important here? I'm specifically referring to fdwOutputPrecision and fdwClipPrecision. I was going to play around with them, but I thought I'd ask here first in case someone else has already been over this ground.

3. The ugliness varies with font size. Small fonts (below 14 "logical device units") look particularly bad. Any rules of thumb on font sizing with regard to rendering quality? Avoid odd number sizes? (or the reverse?)

Any other advice?

MichaelW

I have been working on a font-related app recently, but I'm not far enough to answer your questions other than to say that I have noticed some sizes look better than others.

Running this console app:

;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
.data
    hdc   HDC 0
    hfont HFONT 0
    str1  db "The quick brown fox jumps over the lazy dog.",0
.code
;==============================================================================
start:
;==============================================================================
    HEIGHT = 48

    invoke GetDC, 0
    mov hdc, eax

    ;---------------------------------------------
    ; The font mapper will choose the width based
    ; on the specified height and font.
    ;---------------------------------------------

    invoke CreateFont, HEIGHT,
                       0,
                       0,
                       0,
                       FW_NORMAL,
                       FALSE,
                       FALSE,
                       FALSE,
                       DEFAULT_CHARSET,
                       OUT_TT_PRECIS,
                       CLIP_DEFAULT_PRECIS,
                       CLEARTYPE_QUALITY,
                       DEFAULT_PITCH or FF_DONTCARE,
                       chr$("Trebuchet MS Italic")
    mov hfont, eax
    printf("%x\n\n", hfont)

    invoke SelectObject, hdc, hfont
    push eax

    invoke SetTextAlign, hdc, TA_LEFT or TA_TOP

    invoke TextOut, hdc, 0, 0, addr str1, sizeof str1 - 1

    pop eax
    invoke SelectObject, hdc, eax

    invoke DeleteObject, hfont

    inkey
    exit
;==============================================================================
end start


On my Windows 2000 system with a 21-inch CRT, and on my Windows XP system with a slightly smaller (and less than the best Dell offered in 2003) flat panel display, the font smoothing looks somewhat better on the CRT. Font smoothing is enabled on both systems, with the method on the XP system set to ClearType. If I capture the screens, load them into Paint and zoom the text area 800%, both appear to be using pixel antialiasing, with the difference that the 2000 system is using grayscale, and the XP system is using colors. AFAIK ClearType is supposed to use sub-pixel antialiasing, and I think the sub pixels should be visible in the zoomed image, but since I have never investigated this on a recent system with a really good (read expensive) flat panel display, I'm not sure.

[edit]Well, that was a somewhat dumb statement. The sub pixels could not be visible in a bitmap image composed of pixels.[/edit]
Well Microsoft, here's another nice mess you've gotten us into.

jj2007

Have you tried using the LCD monitor's "native" resolution?

hutch--

General drift is to use fixed pitch fonts for small text and use TT or ClearType fonts for anything else. A CRT is generally kinder t scruffy font appearance but only because they tend not to be as sharp as an LCD screen. he final test is your eye, if it looks OK then its OK.  :biggrin:

NoCforMe

Quote from: jj2007 on June 27, 2012, 05:03:02 PM
Have you tried using the LCD monitor's "native" resolution?

Resolution is set to 1920x1080, which Windows says is the "recommended" setting (also the highest res).

Typeface is a serif font (Georgia), which may be a factor. I notice that sans-serif faces (like the ones used here) tend to look a bit smoother.

jj2007

Quote from: NoCforMe on June 28, 2012, 07:09:48 AM
Resolution is set to 1920x1080, which Windows says is the "recommended" setting

Windows should shut up. What counts is the LCD monitor's native resolution, which might be lower. You cannot force a high resolution on a monitor that displays pixels at a predefined, hardware-specific resolution. Check the monitor's handbook...

dedndave

my LCD seems to work fine, no matter which resoultion i select
maybe this has something to do with it...

Display Properties
Appearance tab
Effects button
Use the following method to smooth the edges of screen fonts: Standard

under XP, i have 2 options, standard and clear type

P1

http://www.microsoft.com/typography/cleartype/tuner/tune.aspx

A Tuneup necessary ???

Regards,  P1   8)

NoCforMe

Quote from: dedndave on June 28, 2012, 09:52:15 AM
under XP, i have 2 options, standard and clear type

Ah, yes, Clear Type: that's a whole 'nother can of worms. (You can read tons of stuff about it on the web.)

Dunno that much about it myself, except that it seems some folks like it and others really hate it (especially with LCDs).

MichaelW

ClearType is specifically aimed at LCD displays.

Dell does not list a native resolution for my 1703FPT display, only a maximum resolution, 1280x1024, which is what I'm running, and as near as I can tell the setting where the fonts looks best.

Well Microsoft, here's another nice mess you've gotten us into.

jj2007

Quote from: MichaelW on June 28, 2012, 03:49:19 PM
Dell does not list a native resolution for my 1703FPT display, only a maximum resolution, 1280x1024, which is what I'm running, and as near as I can tell the setting where the fonts looks best.

The max resolution is the native one. The display is a 1280*1024 grid, and trying to fill that grid with, say, 1600*1280 pixels must imply some, to put it politely, inaccuracies. At such a good resolution you might not even notice them but they are there, and that is what makes the fonts look ugly.

MichaelW

Experimenting further with my XP system, I can use the Effects dialog in the display properties to turn ClearType on and off for some elements in IE, but not for others. For text displayed on the screen DC, ClearType is always on regardless of the setting in the Effects dialog. And for text displayed in Notepad it's always off (correction, it's always off for the default font).
Well Microsoft, here's another nice mess you've gotten us into.

MichaelW

Well Microsoft, here's another nice mess you've gotten us into.