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

Recommended Answers

[QUOTE=daviddoria;1226489]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 …

Jump to Post

All 6 Replies

Re: Outline text 80 80

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()
commented: Great Code, Thanks Luc001 +1
Re: Outline text 80 80

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

Re: Outline text 80 80

Put that code in click handler of button.

Re: Outline text 80 80

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

Re: Outline text 80 80

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.

Re: Outline text 80 80

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

Thanks for your help.

Dave

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.