Link to home
Start Free TrialLog in
Avatar of Hosam
HosamFlag for Egypt

asked on

Outline Text

I want to print some of outlined text (text with a border of different color) in a picturebox using Print statement.

elzohry

Avatar of supunr
supunr

Option Explicit

Private Sub Form_Load()
    Picture1.AutoRedraw = True
    Picture1.CurrentX = 300
    Picture1.CurrentY = 1000
    DrawOutlinedText Picture1, "Hello World", vbRed
    Picture1.CurrentX = 1000
    Picture1.CurrentY = 2654
    DrawOutlinedText Picture1, "Very Long Sentense", vbGreen
End Sub

Private Sub DrawOutlinedText(picbox As PictureBox, strTxt As String, OutlineColour As Long)
    Dim prevCurrX As Long
    Dim prevCurrY As Long
    Dim bdr As Long
   
    bdr = picbox.TextWidth(" ")
    prevCurrX = picbox.CurrentX
    prevCurrY = picbox.CurrentY
    picbox.Line (prevCurrX - bdr, prevCurrY - bdr)-(prevCurrX + picbox.TextWidth(strTxt) + (2 * bdr), prevCurrY - bdr), OutlineColour
    picbox.Line (prevCurrX - bdr, prevCurrY + picbox.TextHeight(strTxt) + bdr)-(prevCurrX + picbox.TextWidth(strTxt) + (2 * bdr), prevCurrY + picbox.TextHeight(strTxt) + bdr), OutlineColour
    picbox.Line (prevCurrX - bdr, prevCurrY - bdr)-(prevCurrX - bdr, prevCurrY + picbox.TextHeight(strTxt) + bdr), OutlineColour
    picbox.Line (prevCurrX + picbox.TextWidth(strTxt) + (2 * bdr), prevCurrY - bdr)-(prevCurrX + picbox.TextWidth(strTxt) + (2 * bdr), prevCurrY + picbox.TextHeight(strTxt) + bdr), OutlineColour
    picbox.CurrentX = prevCurrX
    picbox.CurrentY = prevCurrY
    picbox.Print strTxt
End Sub

Avatar of Hosam

ASKER

dear supunr
What i want is to draw a outline around text letters itself. (as outlined font)

elzohry
or OK, if that is the case then use an outlined font.  For example fonts like....

Swis721 BdCnOul BT
Swis721 BdOul BT

use..

Picture1.Font = "Swis721 BdOul BT"
Picture1.Print "Hello World!"

http://www.free-font-download.com/fonts/monotype-old-style-bold-outline.php
http://www.fontsforsale.com/Yearbook_Outline.htm
http://www.ezgoal.com/channels/fonts/catalogs.asp?CatalogID=888&Ncat

' I am sure you will be able to find heaps more in google search.
Avatar of Hosam

ASKER

I want to print a text with black color, and its outline border with red for example, and this can not be done with outlined fonts.

elzohry
When you say 'outlined' you actually mean selected text?
I'm not sure I understand but this is just a guess.
You don't mean this do you:

Picture1.AutoRedraw = True
Picture1.Print Text1.SelText


Avatar of Hosam

ASKER

I want to make a text with a one pixel glow arount that text

elzohry
I don't know if the following are any use to you. these examples are in MFC (Visaul C++).  

HOWTO: How to Use Paths to Create Text Effects
http://support.microsoft.com/default.aspx?scid=KB;en-us;q128091

HOWTO: Draw TrueType Glyph Outlines
http://support.microsoft.com/default.aspx?scid=KB;en-us;q243285
Avatar of Hosam

ASKER

Dear supunr,
I tried to understand previous examples (that writen to Visual C) bu i failed,
If you can convert any of them to Visual basic,

elzohry
mmm...for 25 points I wonder whether it is worth the trouble....?
ASKER CERTIFIED SOLUTION
Avatar of supunr
supunr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial