I am trying to figure out the best MONOSPACE font size that will allow exactly 60 characters to extend across the canvas. Since the canvas size can vary based on settings, I need to adjust the font size to match. I came up with this test program, but it doesn't seem to do the job. The string should fit in the canvas exactly.
B4X:
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Console")
cvsConsole.Initialize(Panel1)
End Sub
Sub Activity_Resume
Log(Label1.TextSize)
Dim s As String = "01234567 9 123456 19 123456 29 123456 39 1234567890123456 49 123456 59"
cvsConsole.DrawColor(Colors.White)
Dim cw As Float = Panel1.Width
Dim w As Float = cw / cvsConsole.MeasureStringWidth(s, Typeface.MONOSPACE,Label1.TextSize)
Dim TS As Int = Label1.TextSize * w
cvsConsole.DrawText(s,0,14dip,Typeface.MONOSPACE,TS,Colors.Black,"LEFT")
Panel1.invalidate
End Sub