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

Notification

Icon
Error

Options
Go to last post Go to first unread
nokturnal  
#1 Posted : Wednesday, July 12, 2017 12:12:04 PM(UTC)
nokturnal

Rank: Member

Groups: Member
Joined: 3/21/2016(UTC)
Posts: 23

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hey guys & gals,

I was wondering if there was a way to draw text on a path (in my case a circle) without the text becoming distorted.

Here is an example of the distorted text on a path:

UserPostedImage

Now here is how it looks when not on a path:

UserPostedImage

Now, just for fun, here is an SVG representation of the same idea where the text is NOT distorted:

UserPostedImage

Can this be done in graphicsmill without the nightmare scenario of having to manually rotate each character plus all the font measuring that would entail?

Cheers :)

Fedor  
#2 Posted : Wednesday, July 12, 2017 4:17:36 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,660

Thanks: 5 times
Was thanked: 76 time(s) in 74 post(s)
You can use the PathText.Stretch property to specify whether the glyphes should be distorted.

Best regards,

Fedor Skvortsov

nokturnal  
#3 Posted : Thursday, July 13, 2017 3:36:08 AM(UTC)
nokturnal

Rank: Member

Groups: Member
Joined: 3/21/2016(UTC)
Posts: 23

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Originally Posted by: Fedor Go to Quoted Post
You can use the PathText.Stretch property to specify whether the glyphes should be distorted.

Sadly, this did not solve this issue.

Quote:

var pathText = new PathText(text, font, new SolidBrush(col), path, TextAlignment.Center);

pathText.Stretch = false;

graphics.DrawText(pathText);

Quote:

var pathText = new PathText(text, font, new SolidBrush(col), path, TextAlignment.Center);

pathText.Stretch = true;

graphics.DrawText(pathText);

... generate the same visible output (unless I am doing something wrong).

Eugene Kosmin  
#4 Posted : Thursday, July 13, 2017 6:49:58 PM(UTC)
Eugene Kosmin

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 9/19/2006(UTC)
Posts: 505

Was thanked: 41 time(s) in 41 post(s)
Hi,

I just wrote a small code sample, and it gives me pretty different results.

Could you post here your code?

Code:
using (var bitmap = new Bitmap(300, 300, PixelFormat.Format8bppGrayscale, RgbColor.White))
using (var gr = bitmap.GetAdvancedGraphics())
using (var path = new Path())
{
    path.MoveTo(40, 300);
    path.CurveTo(150, 100, 250, 300);
            
    var pathText = new PathText("Text", gr.CreateFont("Arial", 60));
    pathText.Path = path;
    pathText.Alignment = TextAlignment.Center;
    gr.DrawText(pathText);

    pathText.Stretch = false;
    path.Translate(0, -100);
    gr.DrawText(pathText);

    bitmap.Save("result.png");
}

result.png

Edited by user Thursday, July 13, 2017 6:52:32 PM(UTC)  | Reason: add an image

Best regards,

Eugene Kosmin

The Aurigma Development Team

nokturnal  
#5 Posted : Friday, July 14, 2017 3:10:12 AM(UTC)
nokturnal

Rank: Member

Groups: Member
Joined: 3/21/2016(UTC)
Posts: 23

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Yep, I am an idiot... The problem was 100% my code. Sorry to waste your time :)
Users browsing this topic
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.