Opened 16 years ago
Closed 16 years ago
#918 closed Feature Request (Completed)
GUICtrlSetFont() and related
Reported by: | trancexx | Owned by: | Jpm |
---|---|---|---|
Milestone: | 3.3.1.0 | Component: | AutoIt |
Version: | Severity: | None | |
Keywords: | Cc: |
Description
Would it be possible to get another parameter to functions GUICtrlSetFont() and GUISetFont() to be used to select font quality. Or maybe to add more values to attribute parameter?
This appears to be most useful for XP.
Here's the script that shows the difference (is seen on most of the XPs that I could test with - that's a lot actually):
;#NoTrayIcon #include <WinApi.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global Const $DEFAULT_QUALITY = 0 Global Const $DRAFT_QUALITY = 1 Global Const $PROOF_QUALITY = 2 Global Const $NONANTIALIASED_QUALITY = 3 ; WINVER >= 0x0400 Global Const $ANTIALIASED_QUALITY = 4 ; WINVER >= 0x0400 Global Const $CLEARTYPE_QUALITY = 5 ; _WIN32_WINNT >= _WIN32_WINNT_WINXP Global Const $CLEARTYPE_COMPAT_QUALITY = 6 ; _WIN32_WINNT >= _WIN32_WINNT_WINXP Global $iToggled Global $sFontName = "Arial";"Trebuchet MS" Global $sText = "Environment = 3.3.0.0 under WIN_XP/Service Pack 3 X86" & @CRLF & @CRLF _ & "Pointer to a null-terminated string that specifies the typeface name of the font." & @CRLF _ & "The length of this string must not exceed 32 characters, including the terminating null character." & @CRLF _ & "...blah, blah, blah..." Global $hGui = GUICreate("My GUI") GUISetBkColor(0xFFFFFF) Global $hFont = _CreateFontWithDifferentQualityValue() Global $hButton = GUICtrlCreateButton("Change label font quality", 115, 300, 170, 25) Global $hLabelInfo = GUICtrlCreateLabel("- AutoIt font", 170, 350, 100, 25) GUICtrlSetColor($hLabelInfo, 0xFF0000) Global $hLabel = GUICtrlCreateLabel($sText, 110, 30, 180, 180) GUICtrlSetFont($hLabel, 8.5, 400, 2, $sFontName) GUISetState() While 1 Switch GUIGetMsg() Case - 3 ExitLoop Case $hButton _ToggleFont($hLabel, $hFont) EndSwitch WEnd ;cleaning If $hFont Then ConsoleWrite("! On exit delete custom font: " & _WinAPI_DeleteObject($hFont) & @CRLF) EndIf ; The end Func _ToggleFont($hControl, $hFont) If $iToggled Then GUICtrlSetFont($hControl, 8.5, 400, 2, $sFontName) GUICtrlSetData($hLabelInfo, "- AutoIt font") $iToggled = 0 Else GUICtrlSendMsg($hControl, $WM_SETFONT, $hFont, 1) GUICtrlSetData($hLabelInfo, "- custom font") $iToggled = 1 EndIf EndFunc ;==>_ToggleFont Func _CreateFontWithDifferentQualityValue() Local $tLOGFONT = DllStructCreate("int Height;" & _ "int Width;" & _ "int Escapement;" & _ "int Orientation;" & _ "int Weight;" & _ "ubyte Italic;" & _ "ubyte Underline;" & _ "ubyte Strikeout;" & _ "ubyte CharSet;" & _ "ubyte OutPrecision;" & _ "ubyte ClipPrecision;" & _ "ubyte Quality;" & _ "ubyte PitchAndFamily;" & _ "char FaceName[32]") Local $hDC = _WinAPI_GetDC($hGui) Local $LOGPIXELSY = 90 Local $iDCaps = _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSY) _WinAPI_ReleaseDC($hGui, $hDC) DllStructSetData($tLOGFONT, "Height", -8.5 * $iDCaps / 72) DllStructSetData($tLOGFONT, "Weight", 400) DllStructSetData($tLOGFONT, "Italic", 1) DllStructSetData($tLOGFONT, "Quality", $CLEARTYPE_QUALITY) ; CLEARTYPE_QUALITY for example DllStructSetData($tLOGFONT, "FaceName", $sFontName) Local $hFont = _WinAPI_CreateFontIndirect($tLOGFONT) Return SetError(@error, 0, $hFont) EndFunc ;==>_CreateFontWithDifferentQualityValue
Attachments (0)
Change History (6)
comment:1 Changed 16 years ago by TicketCleanup
- Version 3.3.0.0 deleted
comment:2 Changed 16 years ago by Jpm
Not sure It will be the last request of change as ChangeFont as so many parameters which are not accessible.
In my specific case as Cleartype is the default under Vista your example as no effect. The only value which is changing something is $NONANTIALIASED_QUALITY which does not seems an improvement.
Please specify in which context such quality only addition will be a very good improvement.
Thanks
comment:3 Changed 16 years ago by anonymous
Well, XP market share is over 60%. Font smoothing feature is disabled by default (no smart reason these days I guess). I don't know how many users enabled smoothing, but GUIs with regular font are much more unattractive.
The option for me (let's say) is to enable smoothing for user (and disable it later):
Global Const $SPI_SETFONTSMOOTHING = 75 DllCall("user32.dll", "int", "SystemParametersInfo", _ "dword", $SPI_SETFONTSMOOTHING, _ "dword", 0, _ ; 0 -> disable, 1 -> enable smoothing "ptr", 0, _ "dword", 0)
or to use custom font with CLEARTYPE_QUALITY.
Additional values for attribute parameter with AutoIt font functions is desirable from my perspective.
comment:4 Changed 16 years ago by Jpm
I understand That will be the last parameter that we will add to GUICtrlSetFont().
I will not extend more attributes ton such function.
;)
comment:5 Changed 16 years ago by Valik
I don't see why we should add this attribute.
comment:6 Changed 16 years ago by Jpm
- Milestone set to 3.3.1.0
- Owner set to Jpm
- Resolution set to Completed
- Status changed from new to closed
Added in version: 3.3.1.0
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Automatic ticket cleanup.