Font.deriveFont ( AffineTransform trans ); Pass it a transform of the correct scale.
Jon Knight Senior Database Analyst 2525 Horizon Lake Drive, Suite 120 Memphis, TN 38133 [EMAIL PROTECTED] 901.371.8000 - Phone 800.238.7675 - Phone 901.380.8336 - Fax www.FirstData.com First Data's merger with Concord creates "One Company" with enhanced choice, voice and innovation for all customers. -----Original Message----- From: Discussion list for Java 2D API [mailto:[EMAIL PROTECTED] On Behalf Of Augusto Sellhorn Sent: Friday, August 27, 2004 11:09 AM To: [EMAIL PROTECTED] Subject: Re: [JAVA2D] Drawing text inside of a bounding box Thanks for the reply, but I don't want to clip the string, I just want to make it fit within a bounding box. Or find the "best" font size, that given a bounging box and a string, will make the string fit in the box ... Augusto Rosenstrauch, David wrote: >You can set a "clipping region" on the graphics context before painting the >string. Anything that would be painted outside this region gets "clipped" - >i.e., chopped off. That should effectively set a maximum size on the area you >paint the text in. > >See java.awt.Graphics.setClip() > >HTH, > >DR > > > >>-----Original Message----- >>From: Discussion list for Java 2D API >>[mailto:[EMAIL PROTECTED] Behalf Of Augusto Sellhorn >>Sent: Thursday, August 26, 2004 7:55 PM >>To: [EMAIL PROTECTED] >>Subject: [JAVA2D] Drawing text inside of a bounding box >> >> >>I have a situation where users are editing a vector drawing >>in a program >>where the font doesn't match what I display in my renderer. In their >>editing program, all that is saved is a world "height" for >>the text, so >>I can use that to scale and match the font once I draw it. >> >>Now, the font they use in the editing program is monospaced, >>so based on >>the height, i can calculate a "maximum width". Saying that, I'm trying >>to find a way to simply draw a string saying and make sure it doesn't >>exceed this bounding box (height and calculated width). >> >>Is there any easy and fast way to do this? >> >>What I have now tries to match the height, and it does, but >>then when it >>goes for the width it has to decrement the size until the width is not >>greater than the calculated width. There are some cases where >>this takes >>too many iterations and is slow. >> >>So if anybody has any idea what I'm talking about :-), what's a good >>idea to just say, draw this string and don't exceed these bounds? >> >>Thanks >> >>Augusto >> >> =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
