New Bitmap Font Module

Community Forums/Showcase/New Bitmap Font Module

Wiering(Posted 2008) [#1]
Here is a module I made that can display fonts created with the AngelCode Bitmap Font Generator.



Download it at: http://www.wieringsoftware.nl/blitz/


Trader3564(Posted 2008) [#2]
Whoooo! This is one of the best and fastest arround!


Ked(Posted 2008) [#3]
Downloading now! Looks great.


Trader3564(Posted 2008) [#4]
b.t.w.

1. is this crossplatform or Win32 only?!
2. can it do warping? (like max 30 chars on 1 line?)
3. i get black non-transparant boxes behind the characters when adding it to my own engine. Your demo however works fine. Whats wrong? (i have setblend alphablend)
4. could you document the module?

screenshot:



Wiering(Posted 2008) [#5]
1. I only tested it in Win32, so I'm not really sure (please let me know if there are problems!).
2. You mean wrapping? I'll probably add that to the next version (along with ALIGN_JUSTIFY)
3. Turn on alpha blending (the function doesn't do that itself, because you could also be using LIGHT_BLEND)
4. It is mostly documented, you probably have to run Rebuild Documentation to integrate it.


Trader3564(Posted 2008) [#6]
Ok. thanks! Im really looking forward to the update.

About the blending, i said i had ALPHABLEND set :-)
Here is the code:
	'Font test
	SetBlend ALPHABLEND
	SetScale 0.6, 0.6
	myBMF.CallBackChars = "<>0123456789"
	myBMF.SkipChars = "<>"
	myBMF.DrawText ("<>By using <callback functions>, you can make your text look even prettier! You can use~n" + ..
	                "such a function to change the color of the text and <highlight> something for example ...~n" + ..
	                 "~n" + ..
	                 "... or move the characters around:   0 1 2 3 4 5 6 7 8 9~n" + ..
	                 "~n" + ..
	                 "<HAVE FUN!>", 34, 470) 
	SetScale 1, 1


b.t.w. can someone with a Mac reading this, please compile the ready to go BMPFont demo from Wiering and check if it runs with MacOS and/or Linux?!


slenkar(Posted 2008) [#7]
goldstar - in the screenshot you posted it looks fine, i dont see any squares behind the letters,
shadows look like they may be turned on.


Wiering thanks for the module,


andy_mc(Posted 2008) [#8]
goldstar - it's fine, I see the black blocks, looks like a maskimage problem.


Jesse(Posted 2008) [#9]
I am trying to convert the demo to an independent exe by including all of the fnts and pngs as integrated binary files "incbin" but for some rason I get an error when I try to incbin "arial.fnt", I get
"unhandleException:attempt to access field or method of Null object"

here:
Local BMFArial: TBMFont = TBMFont.Create ("incbin::", "Arial.fnt")

this is what I changed:
Incbin "Arial.fnt"

' load font with textures from file
Local BMFArial: TBMFont = TBMFont.Create ("incbin::", "Arial.fnt")


any idea what I should do or is it possible?


tonyg(Posted 2008) [#10]
 Local BMFArial: TBMFont = TBMFont.Create ("incbin::Arial.fnt") 
?
<edit> this suggests a copyright issue though


Jesse(Posted 2008) [#11]
no. you are assuming it's a true font but it's just the name and is a file created by Angel Code Font Generator. it is used to extract the characters from the png file.


Wiering(Posted 2008) [#12]
Goldstar, sorry I overread that :-)
Then you probably have changed AutoImageFlags. Try adding this before creating/initializing the fonts:
AutoImageFlags MASKEDIMAGE | FILTEREDIMAGE


Jesse, you probably didn't include the two .png files with incbin as well. This works for me:

Incbin "Arial.fnt"
Incbin "Arial_00.png"
Incbin "Arial_01.png"
Local BMFArial: TBMFont = TBMFont.Create ("incbin::", "Arial.fnt")


Jesse(Posted 2008) [#13]
yea, thats probably what happened. although, I still haven't tried it. Thanks.

[edit]
by the way, thans for sharing. Really apreciate it.


Trader3564(Posted 2008) [#14]
doh. i forgot to set the maskcolor to 0,0,0. fixed now.


slenkar(Posted 2008) [#15]
Im using bathazar font and I cant get the ' to work.
I export it using the font bitmap generator but cant get it to work with the module - it just uses a space instead


Wiering(Posted 2008) [#16]
You can list all the characters in your font like this:
For Local i: Int = 0 To BMF.Id.length - 1
  Print BMF.Id[i] + ": " + Chr(BMF.Id[i])
Next

You'll probably see that Chr(8216) or Chr(8217) is the one you are looking for.

You could probably also do something with a callback function and draw a comma at position dy=-10 or so, something like:
  if Char="<" dy = -10
  if Char=">" dy = 0

In your text that would be: ... <,> ...


christian223(Posted 2008) [#17]
Excellent mod!, thanks a lot Wiering!.

I have a problem trying to use it in my game though, for some reason all the letters have an offset, for example i do this:

 DrawText("x: " + MouseX() + ".. y: " + MouseY(), MouseX(), MouseY()) 


And the text appears like 100 pixels away from the cursor of the mouse, in both x an y coords, any idea on why this happens???.

EDIT:
Finally i figured it out, its because i had Automidhandle(true), i put it back to false and there is no problem.


Trader3564(Posted 2009) [#18]
Uhm, guys, this doesnt work anymore with the latest version of Angle Font. Can anyone find out how to fix this? The file format seems to have changed a bit...


plash(Posted 2009) [#19]
http://www.blitzbasic.com/Community/posts.php?topic=79976#902310