0

I have some white text I am putting over a very light background. Is there anyway to outline the text in black? After some googling it looks like there are some pretty complicated solutions, but I am looking for something like a check box that says "outline". Is there such a beast?

Thanks,

Dave

2
Contributors
6
Replies
8
Views
6 Years
Discussion Span
Last Post by daviddoria
1

I have some white text I am putting over a very light background. Is there anyway to outline the text in black? After some googling it looks like there are some pretty complicated solutions, but I am looking for something like a check box that says "outline". Is there such a beast?

Thanks,

Dave

Dim grp As Graphics = Me.CreateGraphics

        Dim gp As New Drawing2D.GraphicsPath
        Dim useFont As Font = New Font("Times New Roman", 100, FontStyle.Regular)

        grp.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
        grp.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias

        gp.AddString("sample text", useFont.FontFamily, FontStyle.Regular, 100, New Point(0, 0), StringFormat.GenericTypographic)
        useFont.Dispose()

        
        grp.FillPath(Brushes.White, gp)
        If CheckBox1.Checked Then
            grp.DrawPath(Pens.Black, gp)
        End If

        gp.Dispose()
Votes + Comments
Great Code, Thanks Luc001
0

Hm, I made an empty project and put that code in form load (and removed the "if" for the check box). When I run it, the form is empty. Shouldn't I expect to see "sample text" on the form?

Thanks,

Dave

0

Ah, great, that is exactly what I was looking for. Why doesn't it work if run in form_load?

0

Ah, great, that is exactly what I was looking for. Why doesn't it work if run in form_load?

At Load stage of form GUI is not prepared.

0

If you put this code in the form Paint event instead of form Load, the desired effect is achieved.

Thanks for your help.

Dave

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.