MS Gothic text are not having line spacing

  • Thread starter Thread starter Madhan kumarasamy
  • Start date Start date
M

Madhan kumarasamy

Guest
Hi,

I have tried to draw text using GDI with "MS Gothic" Font but the text are not having line spacing. I have tried with different like "Times New Roman" Font and text are render with proper line spacing.

Code snippet:

Image bitmap = new Bitmap(400, 500,PixelFormat.Format32bppArgb);
Graphics graphics = Graphics.FromImage(bitmap);
graphics.PageUnit = GraphicsUnit.Point;
string[] drawString = { "First","Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth" };
graphics.FillRectangle(Brushes.White, new System.Drawing.Rectangle(0, 0, (int)640,(int)720));
// Create font and brush.
Font drawFont = new Font("MS Gothic", 11,FontStyle.Regular);
//Font drawFont = new Font("Times New Roman", 11,FontStyle.Regular);
SolidBrush drawBrush = new SolidBrush(Color.Black);
StringFormat format = new StringFormat(StringFormat.GenericTypographic);
float x = 72f;
float y = 72f;
foreach (string text in drawString)
{
SizeF size = graphics.MeasureString(text, drawFont, new PointF(0, 0), format);
//graphics.SetClip(new RectangleF(x, 50.65f, size.Width, 15f), System.Drawing.Drawing2D.CombineMode.Replace);
graphics.DrawString(text, drawFont, drawBrush, new RectangleF(x, y, size.Width, size.Height), format);
y += size.Height;
}
graphics.Dispose();
bitmap.Save(@"MSGothic.jpeg");

how to get the line spacing for "MS Gothic" Font?

Regards,

Madhan K

Continue reading...
 
Back
Top