In my application I want to set the Consolas font on some textbox controls at runtime. As Consolas is a ClearType font and only does look good when ClearType is enabled, I want to check if ClearType is enabled.
Can I check if ClearType is enabled?
you can use the FontSmoothingType property of System.Windows.Forms.SystemInformation
public static bool IsClearTypeEnabled
{
get
{
try
{
return SystemInformation.FontSmoothingType == 2;
}
catch //NotSupportedException
{
return false;
}
}
}
Try to use SystemParametersInfo
, see this link for more info:
and a sample code:
Private Declare Function SystemParametersInfo Lib "user32" Alias
"SystemParametersInfoA" (ByVal uAction As Integer, _
ByVal uParam As Integer, ByRef lpvParam As Integer, _
ByVal fuWinIni As Integer) As Boolean
Private Const SPI_GETFONTSMOOTHINGTYPE As Integer = &H200A
Private Const FE_FONTSMOOTHINGCLEARTYPE As Integer = 2
Private Function IsClearTypeEnabled() As Boolean
Dim uiType As Integer = 0
Return SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, uiType, 0)
AndAlso uiType = FE_FONTSMOOTHINGCLEARTYPE
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With