Re: Fitting a string to a box?
Re: Fitting a string to a box?
- Subject: Re: Fitting a string to a box?
- From: Jeff Gilbert <email@hidden>
- Date: Sun, 5 Jun 2005 09:40:36 -0500
Hi Benjamin,On Jun 5, 2005, at 12:20 AM, Benjamin Blonder wrote: 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?
You might want to check out this documentation:
It explains how to perform line-breaking, etc.
later, Jeff |
_______________________________________________
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