TFont for Antonio

TFont for Antonio

Postby Otto » Sat Apr 06, 2013 8:04 am

Hello Antonio,
Would you be so kind to adapt the functionality of
METHOD SaveToText( nIndent ).

It would be fine having similar functions like
METHOD SaveState( aData )
METHOD RestoreState( cInfo ) in xBrowse
for TFont class.

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: TFont for Antonio

Postby Silvio.Falconi » Sat Apr 06, 2013 9:08 am

Otto,
I save the font of mine xbrowses on file Ini

I create a setup for colums,background and fonts Ican call on each table(xbrowse) :


Image

For the fonts then I save on file ini

Sample :
[FntBrowse]
mvBrwFont=Forte:10:Normale;Elephant:10:Normale;Engravers MT:10:Normale;




and then on xbrowse I call the fonts at init for Head,Dataa and Footers


Do you like it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: TFont for Antonio

Postby Otto » Sat Apr 06, 2013 9:36 am

Hello Silvio,
this question is about TFont.

But please post you code. I am sure it is useful for many of us.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: TFont for Antonio

Postby nageswaragunupudi » Sat Apr 06, 2013 5:52 pm

Mr Otto

Can you pls try these two functions?
Code: Select all  Expand view  RUN
//----------------------------------------------------------------------------//

function FontToText( oFont )
return FW_ValToExp(  { ;
   oFont:cFaceName, 0, oFont:nInpHeight, .f., oFont:lBold, oFont:nEscapement, ;
   oFont:nOrientation, nil, oFont:lItalic, oFont:lUnderline, oFont:lStrikeOut, ;
   oFont:nCharSet, oFont:nOutPrecision, oFont:nClipPrecision, oFont:nQuality, ;
   nil, oFont:nPitchFamily }  )
//----------------------------------------------------------------------------//

function FontFromText( cText )
return HB_ExecFromArray( TFont(), "NEW", &cText )

//----------------------------------------------------------------------------//
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TFont for Antonio

Postby Otto » Sat Apr 06, 2013 7:19 pm

Dear Mr. Rao,
thank you for helping me.

If I read the Font from the restored value the result differ from the original Font. I did many tests this afternoon also with the build in method cGenPrg with the same result.
Please see the screen shot.
The height is not like the original.

Best regards,
Otto


Image

Image

Image

Image


This is my test program

Code: Select all  Expand view  RUN

#include "FiveWin.ch"

 Function Main()

    LOCAL oWnd, oSay, cVar
    //LOCAL oFont := TFont():New( 'Calibri', 15.40, 35, .f., .f., 0, 0, 400, .f., .f., .f., 0,3, 2, 1,, 34 )
    LOCAL oFont
    local cText := memoread("RAOfont.txt")
 
    oFont := FontFromText( cText )
 
 
 
 msginfo( "RAOfont.txt" )
 
 //oFont := TFont():New( {"Calibri",0,24,.F.,.F.,0,0,,.F.,.F.,.F.,0,3,2,1,,34} )
 
 DEFINE WINDOW oWnd;
       FROM 1,5 TO 20,65;
       TITLE "Test font. oSay:oFont:lBold is always .t.!"

           @ 12,10 ;
         SAY oSay ;
      PROMPT "ABC Is this bold now?" ;
          OF oWnd ;
        FONT oFont ;
        SIZE 200, 100



 @ 2,10 BUTTON "SelFont";
       SIZE 100,50;
       ACTION oSay:SelFont() OF oWnd

 @ 2,40 BUTTON "cGenPrg";
       SIZE 100,50;
       ACTION ( cVar := oSay:oFont:cGenPrg( cVar ),memowrit("font.txt",cVar) ) OF oWnd

 
  @ 5,40 BUTTON "FontToText";
       SIZE 100,50;
       ACTION (cVar := FontToText( oFont ),memowrit( "RAOfont.txt",cVar) ) OF oWnd
 
 
 ACTIVATE WINDOW oWnd

 RETU NIL
 
 
//----------------------------------------------------------------------------//

function FontToText( oFont )
return FW_ValToExp(  { ;
   oFont:cFaceName, 0, oFont:nInpHeight, .f., oFont:lBold, oFont:nEscapement, ;
   oFont:nOrientation, nil, oFont:lItalic, oFont:lUnderline, oFont:lStrikeOut, ;
   oFont:nCharSet, oFont:nOutPrecision, oFont:nClipPrecision, oFont:nQuality, ;
   nil, oFont:nPitchFamily }  )
//----------------------------------------------------------------------------//

function FontFromText( cText )
return HB_ExecFromArray( TFont(), "NEW", &cText )

//----------------------------------------------------------------------------//
 
 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: TFont for Antonio

Postby nageswaragunupudi » Sat Apr 06, 2013 8:52 pm

I am using this program to check:
Code: Select all  Expand view  RUN
#include "FiveWin.Ch"
#include "hbcompat.ch"
#include "xbrowse.ch"

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oBrw, oTestFont, oCopyFont, oOldFont, cFontText

   DEFINE FONT oTestFont FROM USER
   cFontText   := FontToText( oTestFont )
   if File( 'FONTSAVE.TXT' )
      oOldFont := FontFromText( MemoRead( 'FONTSAVE.TXT' ) )
   endif
   MsgInfo( cFontText )
   oCopyFont   := FontFromText( cFontText )
   MEMOWRIT( 'fontsave.txt', cFontText )

   DEFINE DIALOG oDlg SIZE 500,300 PIXEL
   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE { 'One', 'Two', Date(), 234.56, 'Three', 'Four' } ;
      COLUMNS 1, 1, 1 HEADERS "SELFONT", "COPYFONT", "OLDFONT" CELL LINES NOBORDER

   WITH OBJECT oBrw
      :aCols[ 1 ]:oDataFont   := oTestFont
      :aCols[ 2 ]:oDataFont   := oCopyFont
      if oOldFont != nil
         :aCols[ 3 ]:oDataFont   := oOldFont
      endif
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oTestFont, oCopyFont
   if oOldFont != nil
      RELEASE FONT oOldFont
   endif

return (0)

//----------------------------------------------------------------------------//
function FontToText( oFont )
return FW_ValToExp(  { ;
   oFont:cFaceName, 0, oFont:nInpHeight, .f., oFont:lBold, oFont:nEscapement, ;
   oFont:nOrientation, nil, oFont:lItalic, oFont:lUnderline, oFont:lStrikeOut, ;
   oFont:nCharSet, oFont:nOutPrecision, oFont:nClipPrecision, oFont:nQuality, ;
   nil, oFont:nPitchFamily }  )
//----------------------------------------------------------------------------//
function FontFromText( cText )
return HB_ExecFromArray( TFont(), "NEW", &cText )
//----------------------------------------------------------------------------//
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TFont for Antonio

Postby Otto » Sat Apr 06, 2013 10:11 pm

Dear Mr. Rao,
thank you. Your code is working fine.
I had a mistake here.
FontToText( oSay:oFont )
@ 5,40 BUTTON "FontToText";
SIZE 100,50;
ACTION (cVar := FontToText( oFont ),memowrit( "RAOfont.txt",cVar) ) OF oWnd

But I still have a different behaviour with the build in class oFont:cGenPrg().

with build in:
oFont := TFont():New( 'Verdana', 21.12, 48, .f., .f., 0, 0, 400, .f., .f., .f., 0,3, 2, 1,, 34 )
with your code and this gives the correct behaviour if you use FontFromText( cText )
{"Verdana", 0,-48, .F., .F., 0, 0, , .F.,.F.,.F.,0,3,2,1,,34}


Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: TFont for Antonio

Postby nageswaragunupudi » Sun Apr 07, 2013 6:02 am

Please modify this line method cGenPrg
Code: Select all  Expand view  RUN
     cCode    += "'" + ::cFaceName + "', " + nTrim( ::nwidth ) + ", " + nTrim( ::nHeight ) + ", .f., "
 

as
Code: Select all  Expand view  RUN

      cCode    += "'" + ::cFaceName + "', " + nTrim( ::nInpwidth ) + ", " + nTrim( ::nInpHeight ) + ", .f., "
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TFont for Antonio

Postby Otto » Sun Apr 07, 2013 4:12 pm

Dear Mr. Rao,
this is the output of your file:
{"Calibri", 0, -19, .F., .F., 0, 0, , .F., .F., .F., 0,3, 2, 1, ,34}
This of method cGenPrg:
'Calibri', 0, -19, .f., .f., 0, 0, 400, .f., .f., .f., 0,3, 2, 1, , 34 )
There is a difference in one value.
I think this value is ::nWeight .
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: TFont for Antonio

Postby nageswaragunupudi » Mon Apr 08, 2013 12:25 am

Yes. :nInpWidth and :nWeight
I revised the function too
Code: Select all  Expand view  RUN
//----------------------------------------------------------------------------//
function FontToText( oFont )
return FW_ValToExp(  { ;
   oFont:cFaceName, oFont:nInpWidth, oFont:nInpHeight, .f., oFont:lBold, oFont:nEscapement, ;
   oFont:nOrientation, oFont:nWeight, oFont:lItalic, oFont:lUnderline, oFont:lStrikeOut, ;
   oFont:nCharSet, oFont:nOutPrecision, oFont:nClipPrecision, oFont:nQuality, ;
   nil, oFont:nPitchFamily }  )
//----------------------------------------------------------------------------//
function FontFromText( cText )
return HB_ExecFromArray( TFont(), "NEW", &cText )
//----------------------------------------------------------------------------//
 

Now, these functions and also cGenPrg method of oFont should work reliably
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 75 guests