GraphicsWindow.Title = "Draw Text / Draw Round Text"
Init()
fs = 36
GraphicsWindow.FontSize = 40
GraphicsWindow.FontBold = "False"
txt = "1= How do I make my;2= text like this?;"
color = "1=RoyalBlue;2=HotPink;"
x = 14
y = 40
DrawText()
cx = gw / 2
cy = gh / 2 + 40
DrawRoundText()
Sub Init
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.FontName = "Trebuchet MS"
' width/height [%] of each character in Trebuchet MS font
ratio = "32=30;48=58;49=58;50=58;51=58;52=58;53=58;54=58;55=58;56=58;"
ratio = ratio + "57=58;63=37;65=63;66=59;67=61;68=64;69=57;70=58;71=67;"
ratio = ratio + "72=68;73=28;74=53;75=62;76=55;77=74;78=67;79=70;"
ratio = ratio + "80=59;81=71;82=61;83=51;84=61;85=68;86=62;87=88;"
ratio = ratio + "88=60;89=61;90=56;97=53;98=58;99=51;100=58;101=57;"
ratio = ratio + "102=37;103=50;104=59;105=30;106=37;107=55;108=29;"
ratio = ratio + "109=86;110=59;111=56;112=58;113=58;114=43;115=43;"
ratio = ratio + "116=39;117=59;118=53;119=78;120=55;121=53;122=53;"
EndSub
Sub DrawText
' param txt - text array
' param color - text color array
' param i - index for txt
' param x, y - position
' draw each character
For i = 1 To 2
len[i] = Text.GetLength(txt[i])
GraphicsWindow.BrushColor = color[i]
For p = 1 To len[i]
ch = Text.GetSubText(txt[i], p, 1)
fw = fs * ratio[Text.GetCharacterCode(ch)] / 100
GraphicsWindow.DrawText(x, y, ch)
x = x + fw
EndFor
EndFor
EndSub
Sub DrawRoundText
' param txt - text array
' param color - text color array
' param i - index for txt
' param cx, cy - center position
' calculate width of each text in pixel
For i = 1 To 2
tw[i] = 0
len[i] = Text.GetLength(txt[i])
For p = 1 To len[i]
ch = Text.GetSubText(txt[i], p, 1)
fw = fs * ratio[Text.GetCharacterCode(ch)] / 100
tw[i] = tw[i] + fw
EndFor
EndFor