Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
ChingYen  
#1 Posted : Sunday, May 20, 2012 2:48:00 PM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
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 !

Dmitry.Obukhov  
#2 Posted : Monday, May 21, 2012 1:20:44 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
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.

ChingYen  
#3 Posted : Thursday, May 24, 2012 8:19:39 AM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
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

Dmitry.Obukhov  
#4 Posted : Thursday, May 24, 2012 8:54:08 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
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.

ChingYen  
#5 Posted : Friday, August 3, 2012 4:04:23 PM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
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 !

Dmitry.Obukhov  
#6 Posted : Monday, August 6, 2012 2:10:02 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
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.

Users browsing this topic
Guest
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.