stringHeight wrong or renaming of function

i have the following problem with stringHeight():
for characters like j,p,q,y that go beyond the baseline the calculation of stringHeight only returns the height above the baseline. so if i want to calculate a bounding box i have a problem.

i tried to solve this problem by replacing
cps[i].height = face->glyph->bitmap_top;
with
cps[i].height = face->glyph->bitmap.rows;
in ofTrueTypeFont::loadFont

that solved the bouding-box problem but broke the drawString function of course.
so i think in charProps the member height should be renamed to top and
a new member height should be set to bitmap_rows
stringHeight can then calculate the right bouding box. a stringTop function could also be introduced.

best
joerg

hey good catch ! I didn’t think about that when we coded char props. will take a look and try to implement a fix for 0.05, I always suspected that width was right but height not entirely. thanks for that !! zach

ok I got a fix, will be pretty nice – it’s a bit messy, but coming in 0.05 and will be in the svn soon.

a) uses the new ofRectangle type in ofTypes.h to return the bounding rectangle for a string (likely the most needed thing, as opposed to height or width)

b) it uses the actual positions for the textures (ie same code as drawString / drawChar) and calculates the min/max… instead of drawing.

c) internally uses the rectangle function to get better, more accurate width or height info.

d) doesn’t require any changes to the code so everything that was working before keeps working.

screenshot of it in action:

thanks for pointing out the bug!

take care,
zach

great! a good solution for the problem i think.
now i can have a bounding box around my name :slight_smile:
joerg