Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Nibbles

Making text do what i want it to do. sounds greedy huh.

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

Hi, I'm having a problem with displaying text using NeHe's code. You can see my problem Here. What I'm trying to do is to test the text with boundaries to see if should wrap around to the next line. I'd appreciate any help. btw: the text in the screenshot is just for an example, it's really not gonna be that cheesy Thanks, Scott Email Website
"If you try and don't succeed, destroy all evidence that you tried." Edited by - wojtos on October 16, 2001 1:56:57 AM

Share this post


Link to post
Share on other sites
Advertisement
Hey Scott!!


Just check your length off the text lines, and if they goes
out of your predefined bounderies....just instert a newline!


That should be easy enough.... he he he....


Take Care!

- -- ---[XaOs]--- -- -

[ project fy ]

Share this post


Link to post
Share on other sites
ok, but how do i check the length? I never did spend much time playing with strings

for example:
char *s;
s = "hello";

how do i parse s to see how many characters are in it? and also, if they''re are any spaces.

thanks,
Scott

Share this post


Link to post
Share on other sites
you can use strlen(stringname) to find the length, and to find spaces loop through the string and look for '' '' characters...

Share this post


Link to post
Share on other sites
i think this code will work for ya

  
include <string.h>

char *s;
s="hello";
int length = strlen(s); // length = 5




-------------------------------------------------
Don''t take life too seriously, you''''ll never get out of it alive. -Bugs Bunny

Share this post


Link to post
Share on other sites
It would actually be more complicated than that. You would want to make sure the text doesn''t wrap in the middle of a word.

To do this, you will want to know how many characters fit on a line. Start at that character in your string and walk through the characters in your string backwards from that point and find the first space. Print everything up to that space on that line, truncate the string (remove the space as well) and repeat until everything in your string is printed.

When you''re done with that, visit LMNOpc and download Bitmap Font Builder to make some cool fonts for your program.

Good luck!


ThomW
www.LMNOpc.com

Share this post


Link to post
Share on other sites
Alrighty... I have no idea how to find out how long a string is... in pixels that is. Finding out how many characters is simple (thank you Authustian), but now I have to find out how "wide" each letter is.

Thanks,
Scott

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Er, surely you know how ''wide'' a character is because you drew it to the screen?

Share this post


Link to post
Share on other sites
woj -

If you use textures created by Bitmap Font Builder, you can export a file containing the widths of each character in pixels, or in CharABCWidths. See my site for more information.

Good luck!


ThomW
www.LMNOpc.com

Share this post


Link to post
Share on other sites

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