TextWidth and TextHeight functions?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

TextWidth and TextHeight functions?

Post by Giuliano »

Is it possible somehow to either
a)change the default font that Lua uses
b)calculate the print text height and width of a string (I need this for doing accurate clipping)

If not, would it be possible to add in to the next version ?
flattspott
Posts: 22
Joined: Mon Aug 22, 2005 4:06 am

Post by flattspott »

from counting the pixels on a zoomed in image
s would be a space

font = {h=7, w=5, s= 3}
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Re: TextWidth and TextHeight functions?

Post by Shine »

Giuliano wrote:Is it possible somehow to either
a)change the default font that Lua uses
No, but it is easy to use your own font, see the tiles handling in the snake game and just use as the index for a tile, the characters of the string.
Giuliano wrote: b)calculate the print text height and width of a string (I need this for doing accurate clipping)
Length: string.len(text) * 8, Height: 8.
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Re: TextWidth and TextHeight functions?

Post by LuMo »

Shine wrote:Length: string.len(text) * 8, Height: 8.
note: this works for monospaced fonts only
Giuliano wrote:Is it possible somehow to either
a)change the default font that Lua uses
and you can already access an example on my website (the nick selector, which uses monospaced font [formula as the one of shine above])

greets
Lumo
PS: i already worked a "wordpad" out for a font that is not monospaced (supports, alignment: left, center, right, and auto-wordwrap)
but by now its only written in php.
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Re: TextWidth and TextHeight functions?

Post by Giuliano »

LuMo wrote:
Shine wrote:Length: string.len(text) * 8, Height: 8.
note: this works for monospaced fonts only
Giuliano wrote:Is it possible somehow to either
a)change the default font that Lua uses
and you can already access an example on my website (the nick selector, which uses monospaced font [formula as the one of shine above])

greets
Lumo
PS: i already worked a "wordpad" out for a font that is not monospaced (supports, alignment: left, center, right, and auto-wordwrap)
but by now its only written in php.
I currently do use a monospaced bitmap font but drawing a lot of text requires blitting and it will get slow if I do too much, so instead I use print for some basic in-game captions. It would be nice to be able to change those fonts
Post Reply