Sub SetLabelSize(lbl As Label, txt As String)
Dim dt=72, RapX = 0.9, limit = 0.1 As Float
Dim Can As B4XCanvas
Dim Rec As B4XRect = Can.MeasureText(txt,dt) ' da errore sono due elementi diversi
lbl.Text = txt
lbl.TextSize = dt
Do While (dt > limit) Or (Rec.Height > lbl.Height *RapX) Or (Rec.Width>lbl.Width)
dt = dt / 2
Rec = Can.MeasureText(txt,dt) ' qui da errore
If (Rec.Height > lbl.Height * RapX) Or (Rec.Width>lbl.Width) Then
lbl.TextSize = lbl.TextSize - dt
Else
lbl.TextSize = lbl.TextSize + dt
End If
Loop
End Sub