Re: Stroking text

From: Mike D Sutton (EDais_at_mvps.org)
Date: 10/22/04


Date: Fri, 22 Oct 2004 09:30:19 +0100


> Does anyone know how to stroke text using GDI? I have some white text that
> I'd like to outline with a fine black line. Any suggestions would be
> appreciated. Many thanks!

Open a path bracket on your target DC using BeginPath(), draw your text into it then ClosePath() and StrokePath() to stroke it with
the currently selected pen. This method however will only ever generate aliased edges since GDI pens are not anti-aliased. For a
similar effect you can draw the text offset slightly 4 times diagonally (one pixel off top left, one pixel off top right etc..) then
a final time in the 'real' text position with the background colour, which results in a nicely anti-aliased edge (assuming your
currently selected font is anti-aliased) however it's a somewhat inefficient method and doesn't work well for anything larger than a
couple of pixels offset.
Hope this helps,

    Mike

 - Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: http://EDais.mvps.org/