Printing text with different fonts in a unique row

Printing text with different fonts in a unique row

Postby max » Tue May 19, 2009 7:40 am

I use oPRN:SAY(nrow,ncol,"text",font) of TPrinter to print my text rows.
Which is the simplest way to use more than one font in the same row without retrivieng the right column for each oPRN:say() for printing consecutively my text string ???
Is it possible using only one oPRN:say() for each row with different fonts or not ?? If not... other way ?

I know i can use multiple oprn:say() (one for each font) in the same row, but i note that is not so easy meet the right column... Now i proceed until i meet the right position after many attempts, but i'm sure there must be another way.

Thank you.

Max
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Re: Printing text with different fonts in a unique row

Postby Dietmar Jahnel » Sun May 24, 2009 7:18 am

I'm looking for a solution for the same feature as well...
Nobody?
Thanks,
Dietmar
User avatar
Dietmar Jahnel
 
Posts: 83
Joined: Mon Oct 17, 2005 10:33 am
Location: Austria

Re: Printing text with different fonts in a unique row

Postby ukoenig » Sun May 24, 2009 10:15 am

Hello Dietmar,
maybe You can calculate / make a Function, using GettextWidth and oFont:nSize() ?
"Using Font 1" + Str(nFontWidth) + "Using Font 2"

Length of a given text, using a defined font
----------------------------------------------------
nTXTLG := GettextWidth( hDC, cText ) // cText = given textstring

Space of one Character of a given font
----------------------------------------------
nFontWidth := INT( oFont:nSize() )

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Printing text with different fonts in a unique row

Postby hua » Mon May 25, 2009 6:07 am

Using the printer class, I produced a printout that look something like this:
Image

and here's the code snippet:
Code: Select all  Expand view

nStartCol := INT( oPrinter:nLogPixelX() * 0.10)
nWidth    := INT( oPrinter:nHorzRes() ) - nStartCol
oFHead3  :=TFont():New( "TIMES NEW ROMAN", 0, -16 , .F., .F., 0, 0, 800,,,, 0, 3, 2, 1, oPrinter )
oFTitl1    :=TFont():New( "TIMES NEW ROMAN, 0, -11 , .F., .F., 0, 0, 600,,,, 0, 3, 2, 1, oPrinter )  

// Print others part of header
aHOthers := {                                           ;
              { "
INVOICE       ", cInv                },;
              { "
             ", Nil                 },;
              { "
DATE          ", DTOC( dDate )       },;
              { "
P/O           ", cPO                 },;
              { "
D/O           ", cDO                 },;
              { "
TERMS         ", cTerm               },;
              { "
SALESMAN      ", cSMan               },;
              { "
PAGE NO       ", STRZERO( nPage, 3 ) }, ;
              { "
A/C NO        ", cIden               } ;
            }

nCol1 := nWidth - ( nStartCol + ( nFntWid * ( LEN( aHOthers[ 1,1 ] ) + 17 ) ) )
nCol2 := nCol1 + ( nFntWid * LEN( aHOthers[ 1,1 ] ) )

FOR nHCnt := 1 TO LEN( aHOthers )
   if nHCnt == 1
      nRow += ( oRptFont1:nHeight * 2.5)
      oPrinter:Say( nRow, nCol1, aHOthers[nHCnt,1], oFHead3 )
   else
      oPrinter:Say( nRow, nCol1, aHOthers[nHCnt,1], oFTitl1 )
   endif
   IF aHOthers[ nHCnt, 2 ] != Nil
      IF nHCnt == 1   // Invoice number to be printed in BOLD
         oPrinter:Say( nRow, nCol2, "
: "), oRptFont1 )
         oPrinter:Say( nRow, nCol2 + ( oFHead3:nWidth * 2 ),aHOthers[ nHCnt, 2 ], oFHead3 )
      ELSE
         oPrinter:Say( nRow, nCol2, "
: " + aHOthers[ nHCnt, 2 ], oRptFont1 )
      ENDIF
   ENDIF
   nRow += oRptFont1:nHeight
NEXT


HTH
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1047
Joined: Fri Oct 28, 2005 2:27 am

Re: Printing text with different fonts in a unique row

Postby max » Mon May 25, 2009 12:07 pm

Thank you Uwe and Uha.
Your examples is good for me because it let me know that there is not possibilities other then work with code to meet my request using only the standard class Tprinter.
I supposed it was before, and now i'm sure of it thanks to your examples.
Writing and maintening these many rows of code only for print one row with different fonts is too hard for me: i'm a beginner of FWH. Perhaps in the future, but not now. (i have many other - and unfortunately more urgent! - problems to solve due to my low knowledge of FWH)
So i will study your code, but after your precious replies i think i'll consider this way for me:
- for simple report, i will continue use class Tprinter, accepting to write one oPRN:say() for each font i need. If the print is not so heavy,i want customize many things at a low level, and don't need excellent graphics result, this is the simplest way.
- for more complexes reports and to have a better graphic look, i'm trying "EasyReport 2" (thanks to Otto!): it seems to be a very simple and powerful tool.

Max
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], lzanardo, nageswaragunupudi and 35 guests