Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
How to check if text is over the size for the TextVObject
Rank: Advanced Member
Groups: Guest
Joined: 3/3/2008(UTC) Posts: 185
Thanks: 8 times
|
Hi,
How can we check if the text is bigger than the given TextVObject size?
Kindly advise. Thanks !
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 5/29/2010(UTC) Posts: 1,310
Thanks: 8 times Was thanked: 111 time(s) in 111 post(s)
|
Hi Ching-Yen,
Could you please describe what you need in details? What you try and what you need to get? |
Best regards, Dmitry Obukhov
Technical Support. Aurigma, Inc.
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 3/3/2008(UTC) Posts: 185
Thanks: 8 times
|
Hi, Code:
System.Drawing.RectangleF ctRect = new System.Drawing.RectangleF((float)textX, (float)textY, (float)textWidth, (float)textHeight);
Aurigma.GraphicsMill.WinControls.TextVObject cptxtObj = new Aurigma.GraphicsMill.WinControls.TextVObject(pageDescription, fontName, convertedTextSize, ctRect);
I would like to know if the "pageDescription" is too long / big for the ctRect when using the given fontName, TextSize
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 5/29/2010(UTC) Posts: 1,310
Thanks: 8 times Was thanked: 111 time(s) in 111 post(s)
|
Hi Ching-Yen, Thanks for the details. Sure it is possible. AverageCharWidth property helps us. Please see this code snipped: Code:
System.Drawing.RectangleF ctRect = new System.Drawing.RectangleF(0, 0, 200, 50);
string str = "Aurigma";
//set Aurigma Font class
Aurigma.GraphicsMill.Drawing.Font font = new Aurigma.GraphicsMill.Drawing.Font("Arial", 20);
//set TextVObject
Aurigma.GraphicsMill.WinControls.TextVObject cptxtObj = new Aurigma.GraphicsMill.WinControls.TextVObject(str, font.Name, font.Size, ctRect);
//count chars in str
int count = 0;
foreach (char c in str)
{
count++;
}
//calculate (avarage) width of string
float stringwidth = count * font.AverageCharWidth;
Please note that I use Aurigma.GraphicsMill.Drawing.Font class because standard System.Drawing.Font one does not allow to get AverageCharWidth value.If you have any questions please let me know. Edited by user Thursday, May 24, 2012 8:55:46 PM(UTC)
| Reason: Not specified |
Best regards, Dmitry Obukhov
Technical Support. Aurigma, Inc.
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 3/3/2008(UTC) Posts: 185
Thanks: 8 times
|
Hi Dmitry,
But this will only calculate the "width" but not the height rite? Example, if I have a very long text and I would like it to be auto multiline feed. But I wanna ensure that the multiline will not exit the given size.
Kindly advise. Thanks !
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 5/29/2010(UTC) Posts: 1,310
Thanks: 8 times Was thanked: 111 time(s) in 111 post(s)
|
Hi Ching-Yen,
Unfortunately multiline text is not supported by TextVobject. |
Best regards, Dmitry Obukhov
Technical Support. Aurigma, Inc.
|
|
|
|
Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
How to check if text is over the size for the TextVObject
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.