Solved

Printing Logical Fonts

Posted on 1998-08-24
2
189 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

790 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