AlienStar,
This is how you can get the maximum font size to fit in a label:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <FontConstants.au3>
#include "StringSize.au3"
#include <Array.au3>
$hGUI = GUICreate("Example", 1072, 330)
$cLabel = GUICtrlCreateLabel("", 15, 15, 1072 - 30, 330 - 30, $SS_CENTER + $SS_SUNKEN)
GUICtrlSetBkColor($cLabel, 0xC4C4C4)
GUISetState(@SW_SHOW, $hGUI)
; Create the text to size
$sText = "A. Font Size = "
$iFontSize = "100"
; Pass all the data to the function which will find the max size to fit in the label
$iFontSize = _FindMaxSize($sText & $iFontSize, 1072 - 30, 330 - 30, $FW_BOLD, $GUI_FONTNORMAL, "Arial")
; Put the text into the label and set the font size
GUICtrlSetData($cLabel, $sText & $iFontSize)
GUICtrlSetFont($cLabel, $iFontSize, $FW_BOLD, $GUI_FONTNORMAL, "Arial")
Sleep(1000)
$sText = "Text fit the lable size. Font Size = "
$iFontSize = "100"
$iFontSize = _FindMaxSize($sText & $iFontSize, 1072 - 30, 330 - 30, $FW_BOLD, $GUI_FONTNORMAL, "Arial")
GUICtrlSetData($cLabel, $sText & $iFontSize)
GUICtrlSetFont($cLabel, $iFontSize, $FW_BOLD, $GUI_FONTNORMAL, "Arial")
Sleep(1000)
$sText = "Text2 fit the lable size, Text here is longer.... Font Size ="
$iFontSize = "100"
$iFontSize = _FindMaxSize($sText & $iFontSize, 1072 - 30, 330 - 30, $FW_BOLD, $GUI_FONTNORMAL, "Arial")
GUICtrlSetData($cLabel, $sText & $iFontSize)
GUICtrlSetFont($cLabel, $iFontSize, $FW_BOLD, $GUI_FONTNORMAL, "Arial")
Sleep(1000)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
Func _FindMaxSize($sTxt, $iWidth, $iHeight, $iWeight, $iAttribute, $sFontName)
; Set an initial font size
$iFontSize = 120
While 1
; Size the label needed to fit the string into a label of the correct width
$aRet = _StringSize($sTxt, $iFontSize, $iWeight, $iAttribute, $sFontName, $iWidth)
; Now check if the height will fit
If $aRet[3] < $iHeight Then
; If it does return the font size
ExitLoop
Else
; If not then reduce the font size and try again
$iFontSize -= 1
EndIf
WEnd
Return $iFontSize
EndFunc
Please ask if you have any questions.
M23