Welcome, guest | Sign In | My Account | Store | Cart

Running the script without parameters will enable Clear Type font smoothing. Pass 0, false, off, or disable to turn off Clear Type.

This version requires the ctypes module.

For a version that uses pywin32 see http://code.activestate.com/recipes/578499-enable-clear-type-font-smoothing-on-windows-pywin3/

Python, 20 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import sys
import os
from ctypes import windll

user32 = windll.user32

SPI_SETFONTSMOOTHING      = 0x004B # dec 75
SPI_SETFONTSMOOTHINGTYPE  = 0x200B  # dec 8203
SPIF_UPDATEINIFILE        = 0x1
SPIF_SENDCHANGE           = 0x2
FE_FONTSMOOTHINGCLEARTYPE = 0x2

is_font_smoothing_enabled = 1

if len(sys.argv) > 1:
    if sys.argv[1].lower() not in ['1', 'true', 'on', 'enable']:
        is_font_smoothing_enabled = 0

user32.SystemParametersInfoA(SPI_SETFONTSMOOTHING, is_font_smoothing_enabled, 0,
         SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)