Advertisement

BMFont font size

Started by October 01, 2008 08:09 AM
7 comments, last by WitchLord 16 years, 1 month ago
I've been wondering, what are the units that the BMFont font size is in? It doesn't seem to be standard point size; the glyphs seem to be rendered at about three quarters of a font rendered at the same point size. (i.e. the letter A at size 72 in BMFont is about 3/4 the size of the letter A at 72 point size in MS Paint, Word or Gimp.)
I thought that BMFont passes the parameters to CreateFont and renders them to an HDC, but maybe there's something else going on?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Advertisement
I never gave this any thought. I do exactly what Promit said, i.e. I just create the font with CreateFont using whatever font size the user chose, and then render it to a bitmap using GDI (Actually I currently use GetGlyphOutline, but the result is the same).

Thinking about it, the difference is probably that the font size in BMFont is given in pixels, whereas in the other programs it's given in points, where the size of a point depends on the selected resolution. I don't remember the default ratio between point and pixel size, but it is probably about three quarters, like the size difference you noticed.

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

Out of curiousity I decided to google a bit on this subject and found an interesting article that I believe explains the difference in size that you've noted.

http://groups.google.com/group/microsoft.public.win32.programmer.gdi/browse_thread/thread/397b21d269cf116f

When defining a font size in points you get different results depending on the display settings. The size of a point is 1/72 inches, and the display settings gives the resolution or the number of dots per inch (default seems to be 96 DPI).

Using this information a font of size 72 points would equal a size of 96 in pixels. Which just happens to match exactly with the ratio of three quarters you noted.



I think I'll add a bit of info on this in the documentation for BMFont for the next version. Thanks for bringing up this subject, it's always good when I get to learn something new.

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

In that case the ratio would be equal to 72 over the logical pixels per inch of height the user's computer, typically 96, but it can vary. It'll also be off if the font uses an internal leading height. So, yeah, 3/4 on most computers with most fonts. Any way I can convince you to allow the font size box to accept negative numbers? At least that way I won't need to check the font for internal leading when converting point sizes.

(Edit: your second post wasn't there when I typed this up. :) )
You lost me there. Why would you need to be able to set a negative height?

If you mean to use this to have CreateFont match the value against the character height rather than the cell height, then I don't think a negative height would be the answer, but rather a separate checkbox for setting the mode.

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

Advertisement
Well, allowing negative height seemed like it would be less work for you. But if you want to do the negation yourself depending on a checkbox, go for it.
True, it probably might be easier to just allow the height field be a negative value, but in regards to useability a checkbox with a more descriptive label would be better. :)

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

BMFont 1.11 is now available, with the option to define the font size by character height rather than line height.

Let me know if you find any problems with it.

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

This topic is closed to new replies.

Advertisement