Jump to content
  • Advertisement
Sign in to follow this  
yahn

FreeType string width and height?

This topic is 3735 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

Is there a way to find the length of a string will be before you render each glyph of the string? And if there is not, what is a safe estimate? I thought the font size multiplied by the string length would be a safe guess, but it is showing that it is a little short some times.

Share this post


Link to post
Share on other sites
Advertisement
Query FreeType for the glyphs for each character, and place these in an array. The 'advance' field of each glyph is the width, so loop through your string adding the advance for that particular character.

Of course, this doesn't take tab stops into account, but you probably don't need those.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!