Tag Archives: draw strings

Measure character positions when drawing long strings in C#

The example Measure character positions in a drawn string in C# uses the Graphics class’s MeasureCharacterRanges method to find the positions where characters in a string will be drawn. Unfortunately this method requires you to call a StringFormat object’s SetMeasurableCharacterRanges … Continue reading

Posted in algorithms, drawing, fonts, graphics, strings | Tagged , , , , , , , , , , , , , , , | 2 Comments

Align text drawn by DrawString in C#

This example shows how to use StringFormat objects and Rectangles to align text drawn in in C#. This example’s Paint event handler draws nine strings inside a rectangle, aligning them vertically and horizontally in the nine possible combinations of top/left, … Continue reading

Posted in graphics, strings | Tagged , , , , , , , , , , , , | 2 Comments