Posted 27 March 2020, 10:15 am EST
How can I get rid of the padding that seems be placed when writing text on an Image? I wrote some sample code below, and attached my output. You can see there there is some padding between the letters and the surrounding box. Is there a way to get rid of that?
using (var bmp = new GcBitmap(500, 500, false, 96, 96)) {
using (var g = bmp.CreateGraphics()) {
var rc = new RectangleF(0, 0, bmp.Width, bmp.Height);
g.FillRectangle(rc, ColorTranslator.FromHtml("#000"));
var txtRec = new RectangleF(50, 50, 400, 400);
// Create a text format for the "Hello World!" string:
TextFormat tf = new TextFormat() {
FontSize = 50,
ForeColor = ColorTranslator.FromHtml("#FFF"),
FontStyle = GrapeCity.Documents.Text.FontStyle.Regular
};
// Draw the string (text)
g.DrawString("1234", tf, txtRec, TextAlignment.Leading, ParagraphAlignment.Near, true);
// Draw Outline
g.DrawRectangle(txtRec, new GrapeCity.Documents.Drawing.Pen(Color.Red));
}
bmp.SaveAsPng(@"D:\temp\Outputs\Test.png");
}
```[img]https://gccontent.blob.core.windows.net/forum-uploads/file-094f4397-2d63-4cec-8045-e71249b4dd4a.png[/img]