Jump to content
  • Advertisement
Sign in to follow this  
Khaos Dragon

Free type dimension confusion

This topic is 4027 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. )

Share this post


Link to post
Share on other sites
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!