Solved

Printing Logical Fonts

Posted on 1998-08-24
2
186 Views
Last Modified: 2013-12-02
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?
0
Comment
Question by:janim
2 Comments
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1430802
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, _
      lpszFace:=.Name)
    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

PROC_EXIT:
  Exit Sub

PROC_ERR:
  Resume PROC_EXIT

End Sub

0
 

Author Comment

by:janim
ID: 1430803
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.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now