Free type dimension confusion
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.bitmap, MouseX + someText.glyphs.relativeX + someText.glyphs.left, MouseY - someText.top );
//no need to use someText.glyphs.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. )
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement