Autofit
View as MarkdownDemonstrates how to fit the largest possible text inside a PathBoundedText area.
Code Snippet
using (var bitmap = new Bitmap(400, 400, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetGraphics())
{
var text = new Text();
text.String = "Since 2001, Aurigma have helped software developers add imaging functionality to their applications in a variety of industries. Our image processing Software Development Kit for .NET, Graphics Mill, is a truly powerful product we are proud to have developed.";
text.CharStyle.PostScriptName = "Verdana";
var shapeTextFrame = new ShapeTextFrame();
shapeTextFrame.Shape = new Path();
shapeTextFrame.Shape.DrawEllipse(0, 0, graphics.Width, graphics.Height);
shapeTextFrame.CopyfittingMode = CopyfittingMode.Fill;
text.Frames.Add(shapeTextFrame);
graphics.DrawPath(new Pen(RgbColor.Blue), shapeTextFrame.Shape);
graphics.DrawText(text);
bitmap.Save("FitTextToArea.png");
}
Output
FitTextToArea.png
Used APIs
- Aurigma.GraphicsMill.Bitmap.GetGraphics
- Aurigma.GraphicsMill.Drawing.CharStyle.PostScriptName
- Aurigma.GraphicsMill.Drawing.CopyfittingMode
- Aurigma.GraphicsMill.Drawing.Graphics.DrawPath(Pen,Path)
- Aurigma.GraphicsMill.Drawing.Graphics.DrawText(Text)
- Aurigma.GraphicsMill.Drawing.Path
- Aurigma.GraphicsMill.Drawing.Path.DrawEllipse(Single,Single,Single,Single)
- Aurigma.GraphicsMill.Drawing.Pen
- Aurigma.GraphicsMill.Drawing.ShapeTextFrame
- Aurigma.GraphicsMill.Drawing.ShapeTextFrame.CopyfittingMode
- Aurigma.GraphicsMill.Drawing.ShapeTextFrame.Shape
- Aurigma.GraphicsMill.Drawing.Text
- Aurigma.GraphicsMill.Drawing.Text.CharStyle
- Aurigma.GraphicsMill.Drawing.Text.Frames
- Aurigma.GraphicsMill.Drawing.Text.String