🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

how BMFont works

Started by
3 comments, last by Malandrin 16 years, 7 months ago
Hi, I'm programming a little font exporter ( I can't use yours because the exporter must be part of a game editor ). My question is: how you get the descent info for the characters? ( I think you call it 'yoffset' ) I guess is using GetGlyphOutline() func, but I don't understand how it works. I hope you can help me, thank you. PS: Sorry if this is not the place for this post ( and sorry for my poor english )
Advertisement
It's much more basic than that. Just render the character to a bitmap that you know fits the character (use font height and GetCharABCWidths() to get that info), then simply check how much of that bitmap is used when copying the image to the output texture. If you also want to export kerning pairs, you'll get those from GetKerningPairs().

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Hi,

I think I explain bad again :) what I need to know is the number of pixels under the 'basic line', I mean, the chars 'g' and 'p' i.e. have 3 pixels under the line, and chars 'a' and 'b' 0.

Thanks.
I understand. Well, you need to call GetTextMetrics() to get the information about the font. The returned TEXTMETRIC structure has a member tmAscent that tells you how far from the top the font base is (i.e. the bottom of the capital A). Once you have that you can easily calculate how far below the base line the letters go by examining the rendered character.



AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I got it :), thank you very much.

This topic is closed to new replies.

Advertisement