Sign in to follow this  
kag1

SDL and Fonts

Recommended Posts

Hi, i'm wondering how I would be able to tell how long a line of text is..in say arial (or any font really) The reason I ask is because I want to make a surface that is just long enough to hold the text and no longer are there any such functions that could figure out the length in pixels of a string in a certain font? Or would I have to actually figure out how big (in pixels) each letter is (I don't even know how to do that) and then make a function that figures out the length? thanks

Share this post


Link to post
Share on other sites
Are you using true type fonts or your own font system? Or are you using a lib like SoFont, SDL_TTF, etc? SDL_TTF has a function for finding the length of a string given the font and point size. But then again when SDL_TTF renders a font it renders it to a surface of the needed size automatically.

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