Announcement

Collapse
No announcement yet.

Printer Font Changing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Printer Font Changing

    Any ideas as to why this procedure does not change the printer font?

    - Jim

    function openprintr() as long

    dim lppd as printdlgapi
    lppd.lstructsize=len(printdlgapi)
    lppd.flags=%pd_returndc or %pd_printsetup

    if printdlg(lppd)=0 then
    hprinter&=(-1)
    textheight&=0
    pagelines&=0
    pagecount&=0
    function=hprinter&
    exit function
    end if

    ''devmd&=globallock(lppd.hdevmode)
    ''dim dev as devmode
    ''poke$ varptr(dev),peek$(devmd&,len(devmode))
    ''globalunlock lppd.hdevmode
    ''device$=dev.dmdevicename

    hprinter&=lppd.hdc

    pghght&=getdevicecaps(hprinter&,%vertres)
    pgwdth&=getdevicecaps(hprinter&,%horzres)

    textheight&=pghght&/60 ''tmetrics.tmheight
    textwidth&=pgwdth&/80

    pagelines&=(pghght&/textheight&)-1
    pagecount&=1

    dim lgfnt as logfont

    ''set font
    hfont&=getstockobject(%system_fixed_font)
    getobject hfont&,len(logfont),lgfnt

    lgfnt.lfheight=textheight&
    lgfnt.lfwidth=textwidth&
    lgfnt.lfweight=400
    lgfnt.lfcharset=%oem_charset
    ''lgfnt.lfoutprecision=%out_default_precis
    ''lgfnt.lfquality=%draft_quality
    ''lgfnt.lfpitchandfamily=%fixed_pitch
    lgfnt.lffacename="Arial"

    hfont&=createfontindirect(lgfnt)
    selectobject hprinter&,hfont&

    dim docu as docinfo
    dim xtext as asciiz*80

    ztext="Appname Print Job"
    docu.cbsize=sizeof(docu)
    docu.lpszdocname=varptr(ztext)
    docu.lpszoutput=%null
    startdoc hprinter&,docu

    function=hprinter&
    end function


    -------------
    Jim Seekamp

    Jim Seekamp

  • #2
    There are all sorts of reasons why CreateFont()/CreateFontIndirect() create a font that was not exactly as you wanted. The first possibility is the 'charset' member... try changing this from %OEM_CHARSET to %DEFAULT_CHARSET. There is an important interraction between the facename and the charset parameter... see WIN32.HLP's LOGFONT description for more info.

    The best advise I can offer is to read Petzold or Rector/Newcomer about font selection - the latter goes into some depth about the font selection process.

    The important thing to remember here is that CreateFont() and CreateFontIndirect() are requests for a font, not an explicit directive. Windows makes the "final decision" on the type of font is actually created, based on a complex set of "penalties" depending on how you have specified the font parameters.

    -------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment

    Working...
    X