Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Drawstring Letter Spacing

Is is somehow possible to control letter spacing when using Graphics.DrawString? I cannot find any overload to DrawString or Font that would allow me to do so.

g.DrawString("MyString", 
             new Font("Courier", 44, GraphicsUnit.Pixel), 
             Brushes.Black, 
             new PointF(262, 638));

By letter spacing I mean the distance between letters. With spacing MyString could look like M y S t r i n g if I added enough space.

like image 873
beckelmw Avatar asked Jun 03 '10 19:06

beckelmw


1 Answers

That's not supported out of the box. You'll either have to draw each letter individually (hard to get that right) or insert spaces in the string yourself. You can stretch the letters by using Graphics.ScaleTransform() but that looks fugly.

like image 98
Hans Passant Avatar answered Sep 28 '22 04:09

Hans Passant