Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change font in PCL 2

Status
Not open for further replies.

btt423

Programmer
Jan 28, 2002
31
0
0
US
I'm developing a print engine for a project I'm working on and I'm trying to figure out PCL. I'm currently using an HP4050 and can't get the font change from the default monospaced font.

Here is the example that I was trying:

Dim lhPrinter As Long
Dim lReturn As Long
Dim lpcWritten As Long
Dim lDoc As Long
Dim sWrittenData As String
Dim MyDocInfo As DOCINFO

lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)

If lReturn = 0 Then
MsgBox "The Printer Name you typed wasn't recognized."
Exit Sub
End If

MyDocInfo.pDocName = "AAAAAA"
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString

lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Call StartPagePrinter(lhPrinter)

sWrittenData = Chr(27) & "(s16602T" & "How's that for Magic !!!!" ' should change to arial!!!!

lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
Len(sWrittenData), lpcWritten)
lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)

Can anybody give me any suggestions?

Thanks for your help, Brinson
 
No, you don't understand. You have given an incomplete
font selection.

The typface is just one of several parameters that
describe a font. PCL gives priority to font selection
by the attributes. In order of highest priority these
are the attributes.

1. Symbol Set
2. Spacing (proportional or fixed pitch)
3. Point Size (or pitch if fixed spacing)
4. Style (Upright or italic etc.)
5. Stroke weight(medium bold etc.)
6. Typeface(arial, courier, times etc.)

Notice the the typeface has the lowest priority for
font selection!

Back to your example. First consider that the printer
maintains a table for the selection and will do its
best to meet the request. Any unstated attributes will
revert to whatever is current.

You had started with a fixed pitch font, and then
requested the arial typeface. Arial IS a proportional
font, but you are, by default, still requesting a
fixed pitch font. Because the spacing has a higher
priority than the typeface, you still get a fixed
pitch font.

To be safe, always specify the complete select string.

If you want 12pt med Arial then...

<esc>(s1p12v0s0b16602T should never fail.

There is still the issue of the symbol set which
has the highest priority, but that isn't so much of
an issue with HP internal fonts as many symbol sets
are supported. That may not be true with soft fonts.

Jim Asman
 
Thanks for the information jlasman. It worked like a charm!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top