TerminalView: Compute the character width so that non-fixed font characters are not truncated.

[GB.FORM.TERMINAL]
* BUG: TerminalView: Compute the character width so that non-fixed font characters are not truncated.
This commit is contained in:
Benoît Minisini 2022-09-03 02:40:45 +02:00
parent 19bb0178a8
commit 620ad9c919
3 changed files with 14 additions and 3 deletions

View file

@ -7,8 +7,8 @@ VersionFile=1
Component=gb.image
Component=gb.gui
Component=gb.form
Component=gb.term
Component=gb.net
Component=gb.term
Authors="Benoît Minisini\nFabien Bodard"
TabSize=2
Translate=1

View file

@ -369,13 +369,24 @@ Private Sub UpdateFont()
' Dim hZoom As Image
Dim X As Integer
Dim C As Integer
Dim sTest As String
Dim WM As Integer
With $hView.Font
$LH = .Height
$iAscent = .Ascent
sText = String$(8, "mM0_@$#W")
sTest = "mMOYW0_@$#%"
For I = 1 To Len(sTest)
W = .TextWidth(Mid$(sTest, I, 1))
If W > WM Then
WM = W
sText = Mid$(sTest, I, 1)
Endif
Next
sText = String$(64, sText)
$CW = CInt(.TextWidth(sText) / Len(sText) + 0.5)
W = $CW \ 8

View file

@ -8,7 +8,7 @@
Margin = True
{ TerminalView1 TerminalView
MoveScaled(4,3,63,35)
Font = Font["DejaVu Sans Mono,12"]
Font = Font["Cascadia Code,12"]
Expand = True
Limit = 0
Blink = True