Gradient text with TextRenderer.DrawText

Jun 19 2008 2:51 PM

Hello,

I was wondering if it was possible to draw text with a gradient fill using TextRenderer.DrawText.  I’m currently using Graphics.DrawString and a brush to get the effect I want.  I am getting a large performance increase using TextRenderer.DrawText, but I can’t figure out how to retain the ability to display text with a color gradient.

 

With DrawString:

 

gBrush = new LinearGradientBrush(rect,Color.LawnGreen, Color.DarkGreen,angle,true);

dc.DrawString(aString, boldFont, gBrush, 25,25);

 

With DrawText:

 

TextRenderer.DrawText(e.Graphics, aString, boldFont, aRect, Color.DarkGreen);

 

I imagine this has to be pretty simple because I have yet to find someone to ask this question before me yet, so everone else must be figuring it out, or I am going about this in a tottaly wrong direction.

 

Thanks!


Answers (2)