How can i calculate text length in __pixel__? I use Arial-font. I can't see how to do this??? Each char have different image width...
(copy arial.ttf to your prog directory)
Graphics 640,480,0
Local font:TImageFont=LoadImageFont("Arial.ttf",13)
If Not font End
SetImageFont font
SetBlend ALPHABLEND
SetClsColor 255,255,255
Cls
SetColor 0,0,0
DrawText "1234567890",10,10
gettextwidth("123",font)
Flip
WaitKey
Function gettextwidth(text$,font:TImageFont)
For i=0 To text.length-1
Local c=text[i]
Local glyph:TImageGlyph=font._glyphs[c]
Local image:TImage=glyph._image
Print glyph._x+","+glyph._y+","+glyph._w+","+glyph._h+","+glyph._advance '??????? or what
Next
EndFunction
(copy arial.ttf to your prog directory)
Graphics 640,480,0
Local font:TImageFont=LoadImageFont("Arial.ttf",13)
If Not font End
SetImageFont font
SetBlend ALPHABLEND
SetClsColor 255,255,255
Cls
SetColor 0,0,0
DrawText "1234567890",10,10
gettextwidth("123",font)
Flip
WaitKey
Function gettextwidth(text$,font:TImageFont)
For i=0 To text.length-1
Local c=text[i]
Local glyph:TImageGlyph=font._glyphs[c]
Local image:TImage=glyph._image
Print glyph._x+","+glyph._y+","+glyph._w+","+glyph._h+","+glyph._advance '??????? or what
Next
EndFunction