I want to use Graphics.DrawString to draw characters using individual colors.
The problem is that each time I call DrawString, I have to know where to position it (either using a Point or a Rectangle) relative to the other characters.
This is almost possible when taking into account the kerning and wrapping that happens when you use DrawString in a rectangle with a StringFormat. The StringFormat is important to specify alignment, wrapping, trimming, etc.
Ideally I'd be able to tell DrawString how to color each character individually. The other option is if I can measure a string in a rectangle using a StringFormat and then retrieve the X and Y positions of each character index, so that I can draw each one with its own brush.
I tried to measure each character individually, but that will not work because a combination of characters in a string is not the same width as each character measured on its own.
EDIT: Here is what is happening when I take a string, get the Region array, fill those regions with red and blue alternating, and then try to draw each individual character in those regions:
I am calling DrawString as follows:
g.DrawString(character, font, brush, region.GetBounds(g));
Also tried the following:
Rectangle bounds = Region.GetBounds(g);
g.DrawString(character, font, brush, new PointF(bounds.Left, bounds.Top));
And,
g.DrawString(character, font, brush, region.GetBounds(g), stringFormat);
Same results.