BM Font Character Offsets
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?
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.
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.
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
(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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement