Gui/system default font
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Gui/system default font
How to determine what the default font is on a system or restore a gui to the default font after having set a font? Thanks
Re: Gui/system default font
Here is a function by SKAN (modiefied by me) to find out the Default Font and Font Size
Code: Select all
GuiDefaultFont() ; by SKAN (modified by jNizM)
{
hFont := DllCall("gdi32.dll\GetStockObject", "Int", 17, "Ptr")
VarSetCapacity(LF, szLF := 60 * (A_IsUnicode ? 2 : 1))
DllCall("gdi32.dll\GetObject", "Ptr", hFont, "Int", szLF, "Ptr", &LF)
hDC := DllCall("user32.dll\GetDC", "Ptr", hwnd), DPI := DllCall("gdi32.dll\GetDeviceCaps", "Ptr", hDC, "Int", 90)
DllCall("user32.dll\ReleaseDC", "Ptr", 0, "Ptr", hDC), S := Round((-NumGet(LF, 0, "Int") * 72) / DPI)
Fnt := {}, Fnt.Name := DllCall("kernel32.dll\MulDiv", "Int", &LF+28, "Int", 1, "Int", 1, "Str"), Fnt.Size := S
return Fnt
}
MsgBox % "Font Name:`t" GuiDefaultFont().Name "`nFont Size:`t" GuiDefaultFont().Size
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: Gui/system default font
My 'modernized' version:
Code: Select all
GuiDefaultFont() { ; by SKAN (modified by just me)
VarSetCapacity(LF, szLF := 28 + (A_IsUnicode ? 64 : 32), 0) ; LOGFONT structure
If DllCall("GetObject", "Ptr", DllCall("GetStockObject", "Int", 17, "Ptr"), "Int", szLF, "Ptr", &LF)
Return {Name: StrGet(&LF + 28, 32), Size: Round(Abs(NumGet(LF, 0, "Int")) * (72 / A_ScreenDPI), 1)
, Weight: NumGet(LF, 16, "Int"), Quality: NumGet(LF, 26, "UChar")}
Return False
}
GuiFont := GuiDefaultFont()
MsgBox, 0, Default GUI Font, % "GuiFont:`t`t" GuiFont.Name "`nFontSize:`t`t" GuiFont.Size
. "`nFontWeight:`t" GuiFont.Weight "`nFontQuality:`t" GuiFont.Quality
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Re: Gui/system default font
Thank you both - more complicated than I imagined.
Re: Gui/system default font
Thank you, too. I've found your code, as well as original code by SKAN and tested it a bit.
My question is: how to check the current system font size and font name?
The code provided above seems to show only the default font name and font size. If I change e.g. font size (Windows 10 -> Settings -> Ease of Access -> Display -> Make text bigger) it still shows default values.
Kind regards, mslonik ()
My question is: how to check the current system font size and font name?
The code provided above seems to show only the default font name and font size. If I change e.g. font size (Windows 10 -> Settings -> Ease of Access -> Display -> Make text bigger) it still shows default values.
Kind regards, mslonik ()
My scripts on this forum: Hotstrings Diacritic O T A G L E
Please become my patreon: Patreon
Written in AutoHotkey text replacement tool: Hotstrings.technology
Courses on AutoHotkey
Who is online
Users browsing this forum: kashmirLZ and 114 guests