Page 1 of 1

Simple Font-Smoothing (ClearType) Program for Windows

Posted: Wed Aug 20, 2008 5:07 pm
by ebs
I wrote the following program for someone who wanted a way to control Windows' ClearType font-smoothing from the command line.
The font-smoothing routines may be useful even if you don't want to do it from the command line.

You use the program as follows:

Code: Select all

fs on/off c/s contrast

Examples
--------
Turn font smoothing on, set it to ClearType, and set the contrast to 1000:
fs on c 1000

Turn font smoothing on, set it to Standard:
fs on s

Turn font smoothing off:
fs off

Code: Select all

Procedure FontSmoothingOFF()
  ; turn fontsmoothing off
  SystemParametersInfo_(#SPI_SETFONTSMOOTHING, #False, 0, #SPIF_SENDWININICHANGE | #SPIF_UPDATEINIFILE)
  RedrawWindow_(0, 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_ALLCHILDREN | #RDW_INTERNALPAINT | #RDW_INVALIDATE | #RDW_ERASENOW | #RDW_UPDATENOW);
EndProcedure

Procedure FontSmoothingON(FSType.l, Contrast.l = -1)
  ; turn fontsmoothing on
  SystemParametersInfo_(#SPI_SETFONTSMOOTHING, #True, 0, #SPIF_SENDWININICHANGE | #SPIF_UPDATEINIFILE)
  ; set font smoothing type
  SystemParametersInfo_(#SPI_SETFONTSMOOTHINGTYPE, 0, FSType, #SPIF_SENDWININICHANGE | #SPIF_UPDATEINIFILE)
  ; set font smoothing contrast
  If FSType = #FE_FONTSMOOTHINGCLEARTYPE And Contrast <> -1
    If Contrast < 1000
      Contrast = 1000
    ElseIf Contrast > 2200
      Contrast = 2200
    EndIf
    SystemParametersInfo_(#SPI_SETFONTSMOOTHINGCONTRAST, 0, Contrast, #SPIF_SENDWININICHANGE | #SPIF_UPDATEINIFILE)
  EndIf
  RedrawWindow_(0, 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_ALLCHILDREN | #RDW_INTERNALPAINT | #RDW_INVALIDATE | #RDW_ERASENOW | #RDW_UPDATENOW);
EndProcedure

pOnOff.s = UCase(ProgramParameter())
pFSType.s = UCase(ProgramParameter())
pContrast.s = ProgramParameter()

If pOnOff = "ON"
  If pFSType = "C"
    If pContrast
      FontSmoothingON(#FE_FONTSMOOTHINGCLEARTYPE, Val(pContrast))
    Else
      FontSmoothingON(#FE_FONTSMOOTHINGCLEARTYPE)
    EndIf
  ElseIf pFSType = "S"
    FontSmoothingON(#FE_FONTSMOOTHINGSTANDARD)
  EndIf
ElseIf pOnOff = "OFF"
  FontSmoothingOFF()
EndIf
Regards,
Eric

Re: Simple Font-Smoothing (ClearType) Program for Windows

Posted: Wed Aug 20, 2008 9:58 pm
by PB
Thanks!

Posted: Wed Aug 20, 2008 10:40 pm
by Rook Zimbabwe
Haven't run it yet... I will try it on my wifes computer in a moment... I use FS so I doubt I would see any difference. Heck, I will see what it does to me as well!

Silly question:

So this will enable it even if the user has it turned off?

8)

Posted: Thu Aug 21, 2008 12:12 am
by ebs
So this will enable it even if the user has it turned off?
I think so. I believe this does the same thing as adjusting the Display Properties in the Control Panel.

Regards,
Eric

Posted: Thu Aug 21, 2008 4:12 pm
by Rook Zimbabwe
It does work!

OK, On my wifes cruddy LCD monitor (IBM NetVista All In One!) it looked not so hot... but that was her OBG... but it worked good.

Good Job!