Fitting a string to a box?
Fitting a string to a box?
- Subject: Fitting a string to a box?
- From: Benjamin Blonder <email@hidden>
- Date: Sun, 5 Jun 2005 01:20:06 -0400
I'm trying to use the StringTexture classes that Apple provides for
OpenGL text rendering in some of their sample code. This has a
initWithString:(NSString *)aString withAttributes:(NSDictionary
*)attribs method, which lets you specify the text, the font, the font
size, etc. It works well - the problem is that it doesn't wrap when the
text gets too large. I'd like to be able to use it to draw text that
wraps after a certain width, rather than just sizing the box to be as
large as it would like. For example, I need to make sure it doesn't
draw any boxes wider than the screen. To do this, I think I have to
manually insert line breaks at all the right places. I was going to
write an algorithm that did this (for fixed-width fonts only!), but I
was hoping Apple had provided something already.
I'd like to know if there's anything which takes a string, a font, a
font size, and a width, and inserts line breaks in all the right places
so as to make the string, when drawn, fit into a box with the given
width. Any suggestions?
Thanks,
Benjamin Blonder
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden