The hidden API that estimate the character width of a specific font now returns by default an estimated value for non-fixed fonts.

[GB.GUI.BASE]
* NEW: The hidden API that estimate the character width of a specific font now returns by default an estimated value for non-fixed fonts.
This commit is contained in:
gambas 2021-12-17 13:46:05 +01:00
parent d5514f7120
commit 11c7d60ff4

View file

@ -356,7 +356,7 @@ Static Public Sub DrawRect(X As Float, Y As Float, Width As Float, Height As Flo
End
Static Public Sub _EstimateFixedFontCharWidth(hFont As Font) As Float
Static Public Sub _EstimateFontCharWidth(hFont As Font, Optional bFixedOnly As Boolean) As Float
Dim iSpaceWidth As Integer
Dim I As Integer
@ -368,6 +368,8 @@ Static Public Sub _EstimateFixedFontCharWidth(hFont As Font) As Float
$sLastFont = sFont
If bFixedOnly Then
iSpaceWidth = hFont.TextWidth(" ")
For I = 33 To 255
@ -379,6 +381,8 @@ Static Public Sub _EstimateFixedFontCharWidth(hFont As Font) As Float
Endif
Next
Endif
sText = String$(4, "AbCdEfGh01#@WwmM")
$fLastWidth = hFont.TextWidth(sText) / Len(sText)
Return $fLastWidth