mrmixer
Simon Anciaux
534 posts
|
#7182
How to position character with a negative left side bearing ? 2 years, 8 months ago
Hi, I'm using stb_truetype.h and I've got some questions on how to properly position characters.
I'm using y+ goes up, I've got x0, y0, x1, y1 from stbtt_GetCodepointBox and scaled them. Are the following lines correct ? 1. bitmapY = baseLine + y0; 2. bitmapX = x + leftSideBearing; (Or x + x0 since x0 and leftSideBearing are always the same); 3. Some character like 'j' in the Verdana font have a negative left side bearing. Do I need to not use the left side bearing if it's the first character in the "line" since it will draw "out of bounds" ? This freetype.org page seems to indicate that the left side bearing should always be positive. 4. nextX = x + advanceWidth + kerning( current, next ) |
nothings
Sean Barrett
17 posts
/ 1 project
former pro game developer (Thief etc. @ LookingGlass) |
#7200
How to position character with a negative left side bearing ? 2 years, 8 months ago Edited by Sean Barrett on June 9, 2016, 7:27 p.m.
This is technically outside the scope of stb_truetype; what the font defines the values to and what you do with those values is up to you.
I believe what I've done in the past is used the LSB (or maybe just the left bounding box of the character) to determine where to set the leftmost cursor position. I.e. something like
None |
mrmixer
Simon Anciaux
534 posts
|
#7203
How to position character with a negative left side bearing ? 2 years, 8 months ago
Thanks, I wanted to be sure I wasn't misunderstanding what the lfb was.
|