Printing Logical Fonts

I have created a logical font using WIN32 APIs.  I can output it on a picture box using the "textout" function.
What I need is to convert this to a metafile so I can print it or print it as is.  Is there any way to do this in VB?
Who is Participating?

Improve company productivity with a Business Account.Sign Up

watyConnect With a Mentor Commented:
Here is a function I wrote to print rotated text in a picture box or on the printer. You could modify a bit this function and use it.

Public Sub RotateText(lnghDC As Long, ByVal strText As String, ByVal intAngle As Integer, ByVal lngX As Long, ByVal lngY As Long, fntText As StdFont)
  ' Comments  : Draws rotated text onto a form or picture box
  ' Parameters: lnghDC - hdc of form, picture, usercontrol etc
  '             strText - text to print
  '             intAngle - value between 0 and 360
  '             lngX - X position to print, in pixels
  '             lngY - Y position to print, in pixels
  '             fntText - font object. May be an object of type
  '             'stdFont', or the font property of an existing
  '             control or form
  ' Returns   : Nothing
  Dim lnghNewFont       As Long
  Dim lnghOrigFont      As Long
  Dim lngHeight         As Long
  Dim lngResult         As Long
  On Error GoTo PROC_ERR
  ' take dimension information from passed font
  With fntText
    ' calculate height from font size
    lngHeight = -MulDiv(.Size, GetDeviceCaps(lnghDC, LOGPIXELSY), 72)
    ' create font with specified attributes
    lnghNewFont = CreateFont( _
      nHeight:=lngHeight, _
      nWidth:=0, _
      nEscapement:=intAngle * 10, _
      nOrientation:=intAngle * 10, _
      fnWeight:=.Weight, _
      fdwItalic:=.Italic, _
      fdwUnderline:=.Underline, _
      fdwStrikeOut:=.Strikethrough, _
      fdwCharSet:=.Charset, _
      fdwOutputPrecision:=0, _
      fdwClipPrecision:=CLIP_LH_ANGLES, _
      fdwQuality:=0, _
      PitchAndFamily:=0, _
    End With
  ' Select the new font
  lnghOrigFont = SelectObject(lnghDC, lnghNewFont)
  ' Draw the text into the device context. For more control consider
  ' using the DrawText API
  lngResult = TextOut(lnghDC, lngX, lngY, strText, Len(strText))
  ' Restore the original font
  lnghNewFont = SelectObject(lnghDC, lnghOrigFont)
  ' Cleanup
  DeleteObject lnghNewFont

  Exit Sub

  Resume PROC_EXIT

End Sub

janimAuthor Commented:
i already did this textout function... what i need is to directly print it to the printer device... thanks anyway!  the solution was just simple... i just need to have a print command before doing the textout and print.enddoc to end the printing job.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.