Are there any ready-to-use functions or someone can tell me how to do it manually, knowing the font size and the number of characters in the string?
I tried to do it myself with tips from different sites like: letter width = 0.6* font size , something like this, I do not remember the exact numbers, it does not calculate quite right.
Comments
local mytf = TextField.new(myttf, "my text")
local myttf2 = TTFont.new("fonts/Kenney High Square.ttf", 48)
local mytf2 = TextField.new(myttf2, "my text 2")
local mytfwidth, mytfheight = mytf:getWidth(), mytf:getHeight()
local mytfwidth2, mytfheight2 = mytf2:getWidth(), mytf2:getHeight()
print(mytfwidth, mytfheight)
print(mytfwidth2, mytfheight2)
Likes: MoKaLux
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: MoKaLux