FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

measureText & word-wrapping to fixed width

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
rhosking



Joined: 21 Aug 2006
Posts: 14
Location: UK

PostPosted: Mon Sep 25, 2006 11:47 am    Post subject: measureText & word-wrapping to fixed width Reply with quote

Should Graphics.measureText have another variation which offers the 'clipping' rectangle as a parameter? ie:-

final Size measureText(char[] text, Font font, TextFormat fmt, Rect clip)

This would allow me to calculate the height of a chunk of text which is word-wrapped to a fixed width.

The default for the existing variations would be the current behaviour... (0,0,short.max,short.max).

--------- diff below ---------
1553c1553
< final Size measureText(char[] text, Font font, TextFormat fmt)
---
> final Size measureText(char[] text, Font font, TextFormat fmt, Rect clip)
1558,1559c1558,1559
< rect.left = 0;
< rect.top = 0;
---
> rect.left = clip.x;
> rect.top = clip.y;
1561,1562c1561,1562
< rect.right = short.max; //rect.right.max;
< rect.bottom = short.max; //rect.bottom.max;
---
> rect.right = clip.x + clip.width; //rect.right.max;
> rect.bottom = clip.y + clip.height; //rect.bottom.max;
1581a1582,1584
> final Size measureText(char[] text, Font font, TextFormat fmt) {
> return measureText(text, font, fmt, Rect(0, 0, short.max, short.max));
> }
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Tue Sep 26, 2006 12:51 am    Post subject: Reply with quote

Good idea. New snapshot with overload final Size measureText(char[] text, Font font, int maxWidth, TextFormat fmt)
Only specifying max width, as the other dimensions don't seem to be necessary.
- Chris
Back to top
View user's profile Send private message
rhosking



Joined: 21 Aug 2006
Posts: 14
Location: UK

PostPosted: Tue Sep 26, 2006 2:52 am    Post subject: Reply with quote

Excellent. Thanks Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group