Sign in to follow this  
yahn

FreeType string width and height?

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

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