Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / BMP Font Kit

Author
Message
Sven B
17
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 4th Jan 2011 23:02 Edited at: 7th Jan 2011 09:50
Hello everyone,

Using my knowledge of Image Kit, I made a plugin for bitmap fonts. I intended it to be extremely easy to use (stick to basic functionality) and I think I succeeded.

It's only a very small plugin of 13kB, and the number of commands is only 5, but it's a pretty robust, fast and versatile plugin.



Pretty much any image can be used as a bitmap font, and the characters can be edited. Spacing can also be edited, for all characters, or for a subset of characters if wanted.

Screenshots:


All bitmap fonts on the screenshots were created by Scraggle I think. I know I downloaded them from the 2D board a long time ago.

I hope this will be useful to someone.
Keywords and help files included.

Update 6/01/2011 Attached!

Cheers!
Sven B

Attachments

Login to view attachments
Rich Dersheimer
AGK Developer
13
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 5th Jan 2011 00:36
Wow, this should save a LOT of people a LOT of work! Thank you, thank you, thank you!

baxslash
Valued Member
Bronze Codemaster
15
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Jan 2011 00:42
Fantastic work yet again Sven! Adding it to my collection right now.

Thanks!

The Slayer
Forum Vice President
13
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 5th Jan 2011 01:09
Yep, another great plugin from you, Sven B! Good work.
Just wondering if it would be possible to add a command to animate the fonts? Like changing their colors or shape?

Cheers

SLAYER RULES! YEAH, MAN!!
Diggsey
16
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 5th Jan 2011 02:26
It would be even more useful if you made it possible to draw non fixed-width fonts. Basically, for each character cell in the bitmap, search for the first column of pixels which are not empty from the left and right of the cell to find the width of a character. For the space character you can set it to be 1/3 of the cell size or something, or make it set-able from code.

[b]
Sven B
17
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 5th Jan 2011 09:33 Edited at: 5th Jan 2011 09:34
Thanks guys!
I was doubting whether or not I should post it, but it seems I made the right decision.

Quote: "Just wondering if it would be possible to add a command to animate the fonts? Like changing their colors or shape?"


Hi The Slayer,

It's already possible (though not with an extra command):
You can set the source using BK Set Font Source. This command is very fast, as it only sets a few internal variables of the plugin. Those variables are only used when using BK Text. This means that having one or 10 or 50 bitmap fonts will probably have only small impact on the game speed. So you could have, for example 10 bitmap fonts for each frame of an animation without too much speed loss.

Quote: "It would be even more useful if you made it possible to draw non fixed-width fonts"


Hi Diggsey,

This is also already possible. You can set the spacing of all characters at the same time using BK Set Font Spacing LeftSpacing, TopSpacing, RightSpacing, BottomSpacing or you can specify the spacing of a subset of characters. For example:



Though it might be a good idea to implement some command to find the default spacing...

Cheers!
Sven B

Duke E
13
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 5th Jan 2011 12:33
Very nice SvenB as usual, you provide truly invaluable plugins.

I use your "Image Kit" to make bitmap fonts on the fly from "normal" font characters for my GUI. Easy to do non-fixed widths also as you grab the letter images from "Text width". Have to use a separate array to keep track of the characters x,y origin position on the atlas though.

Regards
Duke
Phaelax
DBPro Master
19
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jan 2011 15:06 Edited at: 6th Jan 2011 15:08
This has been on my "to-do" list for a long time but never seemed to get around to making it. Guess I don't have to now.

Quote: "Have to use a separate array to keep track of the characters x,y origin position on the atlas though."

Can't see why you'd need more than 1 array

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
Stab in the Dark software
Valued Member
19
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 6th Jan 2011 16:27
This is great I have a lot of BMP fonts that I have been waiting to use. Great work

[img][/img]


Custom,intel 3.0GHz Hyper Threaded,4GB RAM,ATI X1500 256mb,
WindowsXP DBpro v7.5 Synergy
The coffee is lovely dark and deep,and I have code to write before I sleep.
Duffer
19
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 6th Jan 2011 20:05
@ SvenB,

This is excellent - DEFINITELY the right decision to post this.

It would be great though if you could do the auto-spacing/alignment command....

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Sven B
17
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 6th Jan 2011 22:37 Edited at: 6th Jan 2011 22:41
Really thanks for the replies guys. I'm glad it'll be useful to someone.

As I said before:
Quote: "Though it might be a good idea to implement some command to find the default spacing..."


So I did:

Update



New features:
- An extra command for finding the spacing has been added: BK Find Font Spacing
- You can specify one of 8 (0-7) Spacing Sets to be used (or just ignore that and use the plugin like before). I added this in order to improve the speed when having several bitmap fonts in one program.
I limited the total of spacing sets to 8 so the total reserved RAM memory for the plugin is limited to a little below 10kB, the equivalent of a 50x50px image in total.

The current method for finding the character spacing is finding the minimum and maximum x and y coordinates of any pixel that is not transparent.
As I was coding the algorithm for finding the spacings automatically, I discovered there are some problems doing it the conventional way:
- I have some bitmap fonts that partially overlap each other. Those edges are detected as a part of the current character, and so it is not cropped.
- A flood fill wasn't much of a solution since it is possible that a character is composed of two separate shapes (i, j, ", %, =, à, ...)

I might have some more ideas on how the program could find the character borders, but I'll see what I do with that.
As always, I'll be updating the first post in a sec.
[edit] Done.

Cheers!
Sven B

Duffer
19
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 7th Jan 2011 09:10
Excellent,

A command to confirm the transparency colour of the image containing the bitmap fonts could be useful...??

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Sven B
17
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 7th Jan 2011 09:49
Quote: "A command to confirm the transparency colour of the image containing the bitmap fonts could be useful...??"


Thanks for your input. However I think you can see this more as a general feature, not really specific to bitmap fonts. Also there are a lot of ways to get around this problem. DBP uses set image colorkey when loading an image, ImageKit has a command IK Set Color To Alpha and IK Replace Image Color and there's always DBP's memblock commands to fall back to...

I'm thinking of adding an extra feature, and that's letter distance (left and right per character, or one global distance, still deciding), so you can control how much space is between 2 letters. I noticed that sometimes you might want to partially overlap letters, which is not possible with this plugin.

Cheers!
Sven B

Duke E
13
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 7th Jan 2011 09:54
@Phaelax
Quote: "Can't see why you'd need more than 1 array"


Cause i use a image "atlas", the images are not stored in an array.

Regards
Duke
Duffer
19
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 7th Jan 2011 19:00
@ Sven B,

Forgot about your other excellent plugin - no worries!

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Scraggle
Moderator
19
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 19th Jan 2011 14:14
Quote: "All bitmap fonts on the screenshots were created by Scraggle I think."


Yep, they look like mine

There are many more to download from my website. Just click on my banner.



Sven B
17
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 19th Jan 2011 18:07 Edited at: 19th Jan 2011 18:16
Quote: "There are many more to download from my website. Just click on my banner."


Thanks! But it looks like I can't access your website. It keeps redirecting me to some search site (usually indicating that the site doesn't exist).

Cheers!
Sven B

[edit] Also, I'm still working on this.

Scraggle
Moderator
19
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 20th Jan 2011 15:25
Oops.

I've fixed the link and added the banner that I thought was there already. Good to hear you are still working on it. I will keep an eye on it.

Login to post a reply

Server time is: 2022-11-29 08:02:53
Your offset time is: 2022-11-29 08:02:53