Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable/disable ClearType without logging out

I need to enable/disable ClearType (or "Adjust the appearance and performance of Windows > Smooth edges of screen fonts") via cmd (or any script like VBS/JS) or from the registry without logging out or restarting Windows.

Maybe it's possible to enable ClearType only for one application.

like image 444
Vitaliy Avatar asked Apr 15 '11 12:04

Vitaliy


People also ask

How do you keep ClearType on?

Click on Advanced display settings followed by ClearType text link at the bottom of the right panel. Step 4. On the screen that follows is where you can enable the option. Put a tickmark in the box that says Turn on ClearType and click on the Next button.

Is ClearType enabled by default?

ClearType is enabled by default in Windows 7, 8, and 10. To turn ClearType on or off, you'll need to launch the ClearType Text Tuner.


2 Answers

Here's a PowerShell way to do it:

Set-ItemProperty 'HKCU:\Control Panel\Desktop\' -Name FontSmoothing -Value "2"

You'll need to log off and back on for it to take effect.

NOTE: strangely the setting doesn't show up as enabled in Performance Options, even though it's clearly turned on:

enter image description here

like image 69
KERR Avatar answered Sep 30 '22 13:09

KERR


Just to add more options, I have the C# version, adding GetFontSmoothing to it.

    [DllImport("user32.dll", SetLastError = true)]
    static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref int pvParam, uint fWinIni);

    const uint SPI_GETFONTSMOOTHING = 74;
    const uint SPI_SETFONTSMOOTHING = 75;
    const uint SPI_UPDATEINI = 0x1;
    const UInt32 SPIF_UPDATEINIFILE = 0x1;

    private Boolean GetFontSmoothing()
    {
        bool iResult;
        int pv = 0;
        /* Call to systemparametersinfo to get the font smoothing value. */
        iResult = SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, ref pv, 0);
        if (pv > 0)
        {
            //pv > 0 means font smoothing is on.
            return true;
        }
        else
        {
            //pv == 0 means font smoothing is off.
            return false;
        }
    }

    private void DisableFontSmoothing()
    {
        bool iResult;
        int pv = 0;
        /* Call to systemparametersinfo to set the font smoothing value. */
        iResult = SystemParametersInfo(SPI_SETFONTSMOOTHING, 0, ref pv, SPIF_UPDATEINIFILE);
        Console.WriteLine("Disabled: {0}", iResult);
    }

    private void EnableFontSmoothing()
    {
        bool iResult;
        int pv = 0;
        /* Call to systemparametersinfo to set the font smoothing value. */
        iResult = SystemParametersInfo(SPI_SETFONTSMOOTHING, 1, ref pv, SPIF_UPDATEINIFILE);
        Console.WriteLine("Enabled: {0}", iResult);
    }
like image 29
Carol Avatar answered Sep 30 '22 12:09

Carol