BM Font Character Offsets

Started by
2 comments, last by WitchLord 17 years, 3 months ago
I'm wondering if I understand the character x,y offsets correctly. Are they supposed to be offsets in relation to other characters on a line? For example, I'm trying to get characters that drop below the base line, (g,y,j) to render correctly in relation to the other characters. However, I've noticed that the y offset for characters like (e,a,o) are the same as (g,y,j). Am I misinterpreting the use and/or orientation of these offsets?

I know only that which I know, but I do not know what I know.
Advertisement
No. Think about it more carefully. Most lower case letters, including the ones you mentioned, share the same top line. The difference for characters like y and g isn't that they're farther down, it's that they're taller. They stretch under the line as a result.
egayoj
Just take a good look at that. Notice that up until j, the tops of the letters are flat all the way across. Even with j, only its dot is above that line.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Alright, that makes a lot more sense. Thanks.

I know only that which I know, but I do not know what I know.
The offsets are relative to the current cursor position. The top left corner of the character glyph should be drawn at

(cursorX + offsetX, cursorY - offsetY)

and the bottom right corner at

(cursorX + offsetX + width, cursorY - offsetY - height)

The cursor position is at the top of the line.

After drawing a character you should advance the cursor position with advanceX.

The character glyph to copy into the rectangle is found at (x,scaleH-y)-(x+width,scaleH-y-height).

(it may differ on your coordinate system, whether (0,0) is at top-left or bottom-left corner)

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

This topic is closed to new replies.

Advertisement