• Advertisement
Sign in to follow this  

Opengl:how To Calculate The Width And Height Of A String Of Char?

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

I just want to know whether it is possible to calculate the width and height of a string of char.

 

suppose i have a string of char and wanted to calculate the width of the whole string "Hello, world!," what functions should i call?

 

char *C = "Hello, world!";

 

for (int i = 0; C != 0; i ++)

            glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, C);
 
if i can calculate the width and height of a single char i can figure out the rest. what is the convention in telling the width of GLUT_BITMAP_HELVETICA_24?
 
THANKS

Share this post


Link to post
Share on other sites
Advertisement

 

I found the solution:

glutBitmapWidth(GLUT_BITMAP_HELVETICA_18, c);

 

 

Outside of the GLUT world you need to handle this by your own. Bitmap fonts are assembled from a texture and certain metrics structs determining each character on that texture. Here it is simply iterating each character and get the mectrics to calculate width and height of a string

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement