Microsoft Small Basic

Program Listing: FHL579-1
' Recommended Fonts 0.4
' Copyright (c) 2013 Nonki Takahashi. All rights reserved.
'
' History:
' 0.1 2013-12-24 Created. (FHL579)
' 0.2 2013-12-24 Added delay before changing font name. (HMK327)
' 0.3 2013-12-24 Changed to draw text in main loop. (FHL579-0)
' 0.4 2013-12-24 Removed delay before changing font name. (FHL579-1)
'
GraphicsWindow.Title = "Recommended Fonts 0.4"
GraphicsWindow.BackgroundColor = "LightGray"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
fs = 16
GraphicsWindow.FontSize = fs
fonts[1] = "Arial"
fonts[2] = "Courier New"
fonts[3] = "Georgia"
fonts[4] = "Times New Roman"
fonts[5] = "Trebuchet MS"
fonts[6] = "Verdana"
fonts[7] = "Tahoma" ' not recommended but default in local
fonts[8] = "Segoe UI" ' not recommended but default in remote
n = Array.GetItemCount(fonts)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.DrawText(10, 10 + fs * 0.3, "Text")
tbox = Controls.AddTextBox(10 + fs * 3, 10)
Controls.SetSize(tbox, fs * 20, fs * 1.8)
Controls.SetTextBoxText(tbox, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
Repaint()
typed = "False"
Controls.TextTyped = OnTextTyped
While "True"
If typed Then
Repaint()
typed = "False"
Else
Program.Delay(200)
EndIf
EndWhile
Sub OnTextTyped
typed = "True"
EndSub
Sub Repaint
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(0, 10 + fs * 2.4, gw, gh - 10 - fs * 2.4)
GraphicsWindow.BrushColor = "Black"
txt = Controls.GetTextBoxText(tbox)
For i = 1 To n
GraphicsWindow.FontName = fonts[i]
GraphicsWindow.DrawText(10, 10 + (i + 1) * (fs * 1.4), fonts[i])
GraphicsWindow.DrawText(10 + fs * 10, 10 + (i + 1) * (fs * 1.4), txt)
EndFor
EndSub