View previous topic :: View next topic |
Author |
Message |
rhosking
Joined: 21 Aug 2006 Posts: 14 Location: UK
|
Posted: Mon Sep 25, 2006 11:47 am Post subject: measureText & word-wrapping to fixed width |
|
|
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 |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Tue Sep 26, 2006 12:51 am Post subject: |
|
|
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 |
|
|
rhosking
Joined: 21 Aug 2006 Posts: 14 Location: UK
|
Posted: Tue Sep 26, 2006 2:52 am Post subject: |
|
|
Excellent. Thanks |
|
Back to top |
|
|
|
|
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
|