Draw text to exact width...
Posted: 2013-09-27T14:37:11-07:00
Ok, so i have a situation where i would like to ideally do the following: I have a known pixel value width (not the same for every image, but known) and a text string of variable length, not more than 15 characters, not less than 3. I have quite a bit of freedom on height (although it is ultimately contrained, not to the extent that my width is, and i don't expect it to be a limitation in this application) I would like to fit this variable text to my known width EXACTLY. using the caption function without a pointsize defined appears to take into account font metrics and leaves white space at the start and end of my string, but i want it to be exactly on the last pixels of the type... I realize i can do this with a trim and rescale, but due to variable image dimensions i would need to render my initial text very large to gurantee no visible scaling artifacts... so yes, I can do it without, but i would love to know if theres a way to EXACTLY limit the *drawn pixel* dimensions - either height, or width, with the other dynamic, and ignoring glyph metrics - of a text string? I can see other applications where this capability could be very usefull if it exits...
thanks!
thanks!