| View previous topic :: View next topic |
| Author |
Message |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Mon Sep 26, 2005 12:56 am Post subject: TextWidth and TextHeight functions? |
|
|
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 ? |
|
| Back to top |
|
 |
flattspott
Joined: 22 Aug 2005 Posts: 22
|
Posted: Mon Sep 26, 2005 1:53 am Post subject: |
|
|
from counting the pixels on a zoomed in image
s would be a space
font = {h=7, w=5, s= 3} |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Mon Sep 26, 2005 1:55 am Post subject: Re: TextWidth and TextHeight functions? |
|
|
| 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. |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Mon Sep 26, 2005 2:34 am Post subject: Re: TextWidth and TextHeight functions? |
|
|
| 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 |
|
| Back to top |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Mon Sep 26, 2005 7:13 am Post subject: Re: TextWidth and TextHeight functions? |
|
|
| 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 |
|
| Back to top |
|
 |
|