This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Draw text to path styling

Chris Jones#31099
Due to requirements for our application regarding stretching text to fit a given area (more complicated than that) i'm using the approach of drawing the text to a path instead, calculating the x,y scaling to fit the target area and then drawing it on the bitmap.

This is working well except that i noticed that the letters i marked as bold using the formatting tags do not appear bold/thicker. However if i create the font as bold (or italic) it does affect the path that is drawn.

Is it by design that drawing text to a path ignores the formatting tags or is this a bug?

I'm hesitant to try to hack this feature together myself using multiple paths and fonts as i dont want to have to deal with the character spacing etc. properties that i'm also relying on.

Thanks
Fedor#31100
Hi Chris,

Could you post code a code sample to reproduce the problem?

The following code successfully applies formatting to the specific part of text:

using (var bitmap = new Bitmap(400, 250, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetAdvancedGraphics())
{
	var pathText = new PathText("Some <span style='bold:true;'>Bold</span> text", 
		graphics.CreateFont("Arial", 42));

	pathText.Path.MoveTo(26, 152);
	pathText.Path.CurveTo(121, 177, 183, 68, 368, 157);

	//Draw text on path
	var path = new Path();
	path.DrawText(pathText);

	//Draw path
	graphics.FillPath(new SolidBrush(RgbColor.Black), path);

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