ClearType and console programmes

651 views
Skip to first unread message

paul.smi...@gmail.com

unread,
Oct 22, 2014, 10:46:13 PM10/22/14
to harbou...@googlegroups.com
On a windows platform with clear type turned on, clearing parts of the screen leaves random lines one pixel wide. this seems to occur after menu to prompts or using characters such as chr(176). Is there any way to turn off clear type just for the console programme other than using the cttune.exe? Ideally I'm looking for a command line to run in a batch file before and after the programme or is there a hbwin function?

paul.smi...@gmail.com

unread,
Oct 25, 2014, 6:21:05 AM10/25/14
to harbou...@googlegroups.com
Hi All

I found one answer and thought I'd post it in case someone searches for it in the future

There are two registry keys that control clear type for the current user:

HKEY_CURRENT_USER\Control Panel\Desktop\FontSmoothing
HKEY_CURRENT_USER\Control Panel\Desktop\FontSmoothingtype

There are Harbour functions to alter registry keys but I'm not experienced enough to use them at present
so using a powershell script <ctype.ps1> I can turn on cleartype with the following command lines

powershell set-executionpolicy remotesigned 
The execution policy only needs to be run once on the platform

powershell -command "&ctype.ps1 1"
1 to  turn on cleartype
<ctype.ps1> must be in the windows path or the full pathname specified

and then turn it off with

powershell -command "&c:\temp\ctype.ps1 0"
0 to  turn off cleartype

The text for ctype.ps1 is:

#requires -version 2.0
param([bool]$enable)

$signature = @'
[DllImport("user32.dll")]
public static extern bool SystemParametersInfo(
    uint uiAction,
    uint uiParam,
    uint pvParam,
    uint fWinIni);
'@

$SPI_SETFONTSMOOTHING      = 0x004B
$SPI_SETFONTSMOOTHINGTYPE  = 0x200B
$SPIF_UPDATEINIFILE        = 0x1
$SPIF_SENDCHANGE           = 0x2
$FE_FONTSMOOTHINGCLEARTYPE = 0x2

$winapi = Add-Type -MemberDefinition $signature -Name WinAPI -PassThru

if ($enable)
{
    [void]$winapi::SystemParametersInfo($SPI_SETFONTSMOOTHING, 1, 0, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
    [void]$winapi::SystemParametersInfo($SPI_SETFONTSMOOTHINGTYPE, 0, $FE_FONTSMOOTHINGCLEARTYPE, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
}
else
{
    [void]$winapi::SystemParametersInfo($SPI_SETFONTSMOOTHING, 0, 0, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
}


Cheers
Paul

Sergy

unread,
Oct 25, 2014, 9:20:10 AM10/25/14
to harbou...@googlegroups.com
Hi Paul.

IMHO, update windows driver for your videocard - is better idea then turning the cleartype off.

WBR,
Sergy

Reply all
Reply to author
Forward
0 new messages