diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5485cfd501..3e9da64f6b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,22 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-19 23:12 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbwin/win_tprn.prg + * contrib/hbwin/win_prn1.c + + WIN_CREATEFONT() extended with 10th parameter which makes + it possible to switch to raw height/width specification. + This is crucial for precise positioning using integer + parameters. Not very elegant parameter, but this class + and low-level interface is already extremely hacky so this + won't really make it any worse. + + WIN_PRN():SetFont() extended with lManualSize option which + maps to above 10th parameter. + + * contrib/hbwin/tests/testprn.prg + + Added some text on the solution for overwritten underline + problem described in test program. + 2010-01-19 21:55 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/gtwvg/wvgdarea.prg ! Deleted method declaration without definition. diff --git a/harbour/contrib/hbwin/tests/testprn.prg b/harbour/contrib/hbwin/tests/testprn.prg index 8d0dc6a876..55a6fa7d54 100644 --- a/harbour/contrib/hbwin/tests/testprn.prg +++ b/harbour/contrib/hbwin/tests/testprn.prg @@ -107,9 +107,9 @@ STATIC PROCEDURE PrnTest( cPrinter, cBMPFile, lAsk ) oPrinter:SetPrc( oPrinter:Prow() + 3, 0 ) oPrinter:Bold( WIN_FW_DONTCARE ) oPrinter:TextOut( "Notice: UNDERLINE only prints correctly if there is a blank line after", .T. ) - oPrinter:TextOut( " it. This is because of ::LineHeight and the next line", .T. ) + oPrinter:TextOut( " it. This is because of :LineHeight and the next line", .T. ) oPrinter:TextOut( " printing over top of the underline. To avoid this happening", .T. ) - oPrinter:TextOut( " you can to alter ::LineHeight or use a smaller font" ) + oPrinter:TextOut( " you can to alter :LineHeight or use a smaller font, or use :SetBkMode( WIN_TRANSPARENT )" ) oPrinter:NewLine() oPrinter:NewLine() oPrinter:SetFont( "Lucida Console", 18, 0 ) // Large print diff --git a/harbour/contrib/hbwin/win_prn1.c b/harbour/contrib/hbwin/win_prn1.c index b6dc3e61e4..13c2385530 100644 --- a/harbour/contrib/hbwin/win_prn1.c +++ b/harbour/contrib/hbwin/win_prn1.c @@ -419,18 +419,29 @@ HB_FUNC( WIN_CREATEFONT ) { HFONT hFont; void * hFontFace; - int iHeight = hb_parni( 3 ); - int iMul = hb_parni( 4 ); - int iDiv = hb_parni( 5 ); + int iHeight; int iWidth; int iWeight = hb_parni( 6 ); iWeight = iWeight > 0 ? iWeight : FW_NORMAL; - iHeight = -MulDiv( iHeight, GetDeviceCaps( hDC, LOGPIXELSY ), 72 ); - if( iDiv ) - iWidth = MulDiv( abs( iMul ), GetDeviceCaps( hDC, LOGPIXELSX ), abs( iDiv ) ); + + if( hb_parl( 10 ) ) /* Ugly hack to enable full control for caller */ + { + iHeight = hb_parni( 3 ); + iWidth = hb_parni( 5 ); + } else - iWidth = 0; /* Use the default font width */ + { + int iMul = hb_parni( 4 ); + int iDiv = hb_parni( 5 ); + + iHeight = -MulDiv( hb_parni( 3 ), GetDeviceCaps( hDC, LOGPIXELSY ), 72 ); + + if( iDiv ) + iWidth = MulDiv( abs( iMul ), GetDeviceCaps( hDC, LOGPIXELSX ), abs( iDiv ) ); + else + iWidth = 0; /* Use the default font width */ + } hFont = CreateFont( iHeight, iWidth, diff --git a/harbour/contrib/hbwin/win_tprn.prg b/harbour/contrib/hbwin/win_tprn.prg index 80c5d733ad..7310dccf1f 100644 --- a/harbour/contrib/hbwin/win_tprn.prg +++ b/harbour/contrib/hbwin/win_tprn.prg @@ -89,7 +89,7 @@ CREATE CLASS WIN_PRN METHOD NewPage( lDelay ) // If lDelay == .T. then new page is not created immediately but just before 1-st output METHOD CheckPage() METHOD GetDocumentProperties() - METHOD SetFont( cFontName, nPointSize, xWidth, nBold, lUnderline, lItalic, nCharSet ) + METHOD SetFont( cFontName, nPointSize, xWidth, nBold, lUnderline, lItalic, nCharSet, lManualSize ) // NB: xWidth is in "CharactersPerInch" // _OR_ { nMul, nDiv } which equates to "CharactersPerInch" // _OR_ ZERO ( 0 ) which uses the default width of the font @@ -371,6 +371,7 @@ METHOD StartPage() CLASS WIN_PRN lChangeDP := .T. ENDIF IF lChangeDP + HB_TRACELOG( "setdoc", nLFormType ) win_SetDocumentProperties( ::hPrinterDC, ::PrinterName, ; nLFormType, lLLandscape, , ; nLBinNumber, nLDuplexType, nLPrintQuality, ; @@ -441,7 +442,7 @@ METHOD GetDocumentProperties() CLASS WIN_PRN // An array {nMul,nDiv} is used to get precise size such a the Dot Matric equivalent // of Compressed print == 16.67 char per inch == { 3,-50 } // If nDiv is < 0 then Fixed width printing is forced via ExtTextOut() -METHOD SetFont( cFontName, nPointSize, xWidth, nBold, lUnderline, lItalic, nCharSet ) CLASS WIN_PRN +METHOD SetFont( cFontName, nPointSize, xWidth, nBold, lUnderline, lItalic, nCharSet, lManualSize ) CLASS WIN_PRN LOCAL cType IF cFontName != NIL ::FontName := cFontName @@ -471,7 +472,7 @@ METHOD SetFont( cFontName, nPointSize, xWidth, nBold, lUnderline, lItalic, nChar IF nCharSet != NIL ::fCharSet := nCharSet ENDIF - IF ( ::SetFontOk := ! Empty( ::hFont := win_CreateFont( ::hPrinterDC, ::FontName, ::FontPointSize, ::FontWidth[ 1 ], ::FontWidth[ 2 ], ::fBold, ::fUnderLine, ::fItalic, ::fCharSet ) ) ) + IF ( ::SetFontOk := ! Empty( ::hFont := win_CreateFont( ::hPrinterDC, ::FontName, ::FontPointSize, ::FontWidth[ 1 ], ::FontWidth[ 2 ], ::fBold, ::fUnderLine, ::fItalic, ::fCharSet, lManualSize ) ) ) ::fCharWidth := ::GetCharWidth() ::CharWidth := Abs( ::fCharWidth ) ::CharHeight := ::GetCharHeight()