Using Tiled Background for Image fonts

Post your own tutorials, guides and demos.

Post » Tue Nov 09, 2010 3:50 am

Here is an example of the using image fonts with the Tiled background object. It uses the "set image offset" action to select letters from the image. The only requirement is the image has to be power of two height and width.

[url:1ygw3nyc]http://dl.dropbox.com/u/5426011/examples2/imageFontpy.cap[/url:1ygw3nyc]
made in 0.99.96

This is not intended to be a replacement of Lucid's Sprite font object. But it gives the advantage of being able to load a different font at run-time with a single load image action, and the ease of editing all the characters in one image.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Tue Nov 09, 2010 4:19 am

Cool.
I remember someone doing something like that with U, and V on a distort map.
Guess you could probably do that with the offset, and pattern fx as well.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Tue Nov 09, 2010 7:47 am

Ach. Recursive functions make my head hurt a bit. Other than that, this is pretty cool ;)

It took me about 10 minutes of staring at that code to figure out how the imageFont object placement worked... And I had no idea about how SetImageOffset can be used like this. Nice.

I did notice a problem, though. For some reason, 'imageFont: Destroy' does not seem to be working, and the debugger shows a couple thousand objects by the time the message is fully displayed, and the number keeps quickly rising beyond that.
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Tue Nov 09, 2010 11:09 am

That's a nice method. I remember something similar done by lucid himself, before the SpriteFont object was even created. It didn't use Python at all though.

Which brings me to the question why Python is being used here. From quickly looking at the script (and not being a Python expert at all) I do believe you could do this just fine by events only.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Tue Nov 09, 2010 5:13 pm

sad to say, maybe this method not maches to korean (hangul) :(
same in japaness (nihongo) chiness (?)

But it still can be a good method :)
B
45
S
9
G
7
Posts: 73
Reputation: 7,518

Post » Tue Nov 09, 2010 5:37 pm

Here's a non-python version with a different font for good measure:
[url:23bxwgy1]http://dl.dropbox.com/u/5426011/examples2/imagefont2.cap[/url:23bxwgy1]

I originally was going to upload a non-python version like this but I had a random crash and lost the whole thing.

@Silent Cacophony
This version no longer uses recursion and the objects do get destroyed now.

EDIT:
Here's where I'm getting the fonts:
[url:23bxwgy1]http://www.algonet.se/~guld1/freefont.htm[/url:23bxwgy1]
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Tue Nov 09, 2010 6:13 pm

I like the non-python version best, and it fits perfectly into one of my ideas. Many thanks.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,841
Reputation: 48,283


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 1 guest