Sign in to follow this  
Khaos Dragon

Free type dimension confusion

Recommended Posts

Khaos Dragon    196
As you can see in this image, I am trying to find the minimum height needed to enclose a string of text rendered in a certain freetype font. From the picture, you can see that this is different than finding the max glyph height. I have been frustrated to my end's wits trying to do this with my current font face's global metrics. I have noticed some really weird things... such as the fact that the global height does not seem to depend on the font size I set.. Basically to prevent confusion I'll begin from where I originally started. For drawing my text I basically do.... for( int i = 0; i < someText.glyphs.size(); i++ ) { draw( glyph[i].bitmap, MouseX + someText.glyphs[i].relativeX + someText.glyphs[i].left, MouseY - someText[i].top ); //no need to use someText.glyphs[i].relativeY since it is always zero } This seems to render correctly, the problem is setting the minimum height for my text background. If I just do draw( background.bitmap, mouseX, mouseY ) my background shows up exactly below the baseline of the font.. ( this means for the string "abcj", the top of my background is located right below the letters a, b, and c although the letter j partially goes into it. )

Share this post


Link to post
Share on other sites
Khaos Dragon    196
well I developed a way to do it by iterating over each possible glyph whenever I set a font size and determining the max y and min y positions. This had been something I wanted to avoid, but I suppose if this only happens on size changes, any worries about this being less efficient are not that huge.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this