Skip to main content
GameDev.net gamedev.net
🔒 Locked

BMFont bug

Started by Sly Mar 4, 2005 at 11:40 PM 15 replies 6k views
Original Post
Sly
Sly
Hiya WitchLord. It's me again. The one known user of BMFont (or so it seems) :) How is the investigation going into the previous bug I reported (Tahoma not being available in the font list) and suggestion (being able to output a 32-bit TGA with the font image in the alpha channel)? I know you've been busy with AS 2.0. I am having trouble with one font that gets the first or last column of pixels cut off from some characters (particularly 'o' and 'O' characters). Here is a sample of the output by BMFont with some of the problem characters highlighted. The font I used is available here. Would you perhaps be willing to release the source to BMFont so I could try fixing the bugs here?
WitchLord
WitchLord
I'm sorry that I didn't fix the Tahoma bug earlier. I had some time over today and decided (because of your post today) to take a look at the problem. It turns out that the fix is quite simple, just show the face name instead of the full name when enumerating the fonts.

I downloaded the font you used, but I haven't been able to reproduce the problem with the cropped characters. What settings are you using (font size, aliasing, etc)? Does the problem show up in the preview window?

I'll see if I can't implement the alpha channel output today as well. It shouldn't be that difficult.

About releasing the source code. Yes, I've been thinking about open sourcing the project, but I'm not ready to do that just yet. We'll see when that will be.

Besides I just let a guy have the source code for a small donation, thus it wouldn't be right to release the code for free so soon after. Though I did tell him that I had plans to open source it.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
intransigent-seal
intransigent-seal
I use it too! Good tool.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
WitchLord
WitchLord
It's possible that it is a problem with GDI. What OS are you using?

If it is indeed the GDI that is outputting the characters cropped, then I may have to implement a work around for those cases.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
WitchLord
WitchLord
I didn't manage to reproduce the cropping bug, but I decided to release a new version of BMFont today anyway. Version 1.1 is now available with the following changes:

- The font list has been corrected. (e.g. Tahoma is now shown instead of Tahoma Bold)
- The output texture can be saved in both 8bit and 32bit TGAs. For 32bit TGAs the font data goes into the alpha channel and the color channels are set to white.
- The character spacing is now also adjustable. The spacing can be set to 0 to save space, or set to a larger number to minimize artifacts in texture filtering.

I'll come back with a fix for the cropping bug as soon as I can figure out what is happening.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
Sly
Sly
Thanks for the quick response. The new 32-bit texture option works well.

I'm still getting the first or last column of pixels cut off some characters as shown in the original post. That sample was done with the BeinetCondensed font at a size of 24 and anti-aliasing set to 1. I'm using Windows XP with SP2.

If I use an anti-aliasing value of 2, then problem goes away. But then I get single pixel horizontal lines in characters like 'H' and 'F' appearing fuzzy from the anti-aliasing.
WitchLord
WitchLord
Strange, I use WinXP SP1 and this is what I get using the same settings:



As you can see, there is no cropping error. I doubt it has anything to do with SP2, but who knows. Have you tried generating the font on another computer?

Anyway, you can use the font I generated if you wish. The files are here: bc.fnt, bc_00.tga.

Even more interesting is that it doesn't always crop the characters on the same side.

Even if I increased the size of the rectangle drawn to not crop the characters, I don't think it would provide a good result since the character spacing would still be irregular.

I'll see what I can do.

Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
WitchLord
WitchLord
A side by side comparisons gives some interesting leads:



It looks like when your font was generated the font is off by a half-pixel or so. Which is especially visible on the rectangles for the non-visible characters.

Maybe I can find a way to allow the user to adjust this offset manually.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
Sly
Sly
One thing I just thought of. Do you have ClearType font smoothing enabled in Display Properties/Appearance/Effects? I have it enabled because I work with LCD monitors. I thought of that because the anti-aliasing in those images looked different. I cannot test this theory at the moment because I am at work.
WitchLord
WitchLord
I have only enabled the normal font anti-aliasing in XP, i.e. no ClearType.

I think you may have nailed the bug with this one. From what I read and understand of ClearType this is likely the cause of the cropped characters.

I'll have to experiment with this when I get home. I'll probably have to add a warning to turn off ClearType, if I can't find a way to turn it off automatically while drawing the characters in the texture. I hope there is at least a way to detect that ClearType is turned on.

In the meantime, maybe you can turn off ClearType when generating the font textures.

Regards,
Andreas

[Edited by - WitchLord on March 8, 2005 8:37:34 AM]
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
WitchLord
WitchLord
I have confirmed that it really is ClearType that is causing the characters to be cropped. And I have also found which registry keys that identify that ClearType is turned on.

Now I just have to see if there is a way I can turn off ClearType temporarily while drawing the texture. It will probably work by changing the registry just before creating the DC and then restore it after releasing the DC again. If that is possible then I will implement it like that, otherwise I will just detect that ClearType is turned on and ask the user to manually turn it off.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
Sly
Sly
Do you use CreateFont to create the font? Perhaps you could try changing what you pass in for dwQuality.
WitchLord
WitchLord
If I remember correctly I do indeed use CreateFont(). (Is there any other way?)

However, I do not believe I will be able to turn off ClearType this way, because I want font smoothing but not ClearType, and I believe that ClearType is turned on by default if you choose font smoothing (if the system has ClearType turned on, that is). I will give it a try though and see what happens.

Thanks for the tip.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
desertcube
desertcube
I haven't used the program in question (sorry), but the way I draw fonts in OpenGL is to use freetype. Since it renders the font from the actual file and doesn't use windows (as it's platform independent), I don't think it'll suffer from clear type (I've never seen any difference when I use cleartype or not, but I haven’t really looked closely!)

There's even a tutorial on nehe's website (here) that shows how to use it in OpenGL.

Hope it's relevant!
WitchLord
WitchLord
FreeType may come in handy if I one day decide to port the program to other platforms than Win32. It's also a good alternative to D3DXFont used by many DirectX developers. Thanks for the link.

For now, I think I can bypass ClearType without too much trouble while still using GDI, I just need to find the time to actually do the tests.

Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
WitchLord
WitchLord
I just uploaded BMFont 1.2, which fixes the last known bug.

Steve, you were right in that changing the value for dwQuality resolved the problem. As a bonus I added the option to turn on/off windows font-smoothing manually.

Thanks for all the feedback. If you have any more suggestions, make sure to let me know so that I can make the tool even better.

Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
Sly
Sly
Excellent. I'll give it a go tonight.

Thanks for your prompt help on these bugs.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.