[BUG] in source/font.prg and a question

[BUG] in source/font.prg and a question

Postby AnjaK » Wed Jun 19, 2019 9:06 am

Hello,

I'm facing this error in FWH1905:
Code: Select all  Expand view

Time from start: 0 hours 0 mins 0 secs
   Error occurred at: 06/19/19, 10:53:54
   Error description: Warning BASE/1004  Message not found: TFONT:CCLASSNAME

Stack Calls
===========
   Called from: source\rtl\tobject.prg => TFONT:ERROR( 0 )
   Called from: source\rtl\tobject.prg => TFONT:MSGNOTFOUND( 0 )
   Called from: source\rtl\tobject.prg => TFONT:CCLASSNAME( 0 )
   Called from: .\source\classes\FONT.PRG => TFONT:SAVETOTEXT( 473 )
   Called from: _fontTests.prg => MAIN( 8 )
 


with this test code:
Code: Select all  Expand view

#include "Fivewin.ch"

Function Main()
    LOCAL oFont, oFile
    LOCAL cFontText
   
    oFont := TFont():New("Segoe UI Bold", 0, -10, , , .T., , , , .F., .F.)
    cFontText := oFont:SaveToText(0)
    ? cFontText
   
    oFile := TTxtFile():Create("_fontAsTxt.txt")
    oFile:Open()
    oFile:AppendLn(cFontText)
    oFile:End()
   
RETURN nil
 


I found this:
Code: Select all  Expand view

cInfo := Space( nIndent ) + "OBJECT " + If( nIndent > 0, "::", "" ) + ;
            "oFont AS " + ;
            If( nIndent > 0, Upper( Left( ::ClassName(), 2 ) ) + ;
            Lower( SubStr( ::ClassName(), 3 ) ), ::cClassName ) + ;
            CRLF + CRLF
 


There is no ::cClassName defined.

But I'm searching for a way to save the used font as text (in DBF table) and create the object from that text:
Code: Select all  Expand view

 OBJECT ::oFont AS TFont

    ::cFaceName = "Segoe UI Bold"
    ::lBold = .F.

 ENDOBJECT
 


Is there a way to do this?

Thank you in advance

Sincerely

-----------------

Additional info:
I tried the obvious like this:
Code: Select all  Expand view

Function Main()
    LOCAL oTest
   
    oTest := TTestFont():New()
    XBrowse(oTest)
RETURN nil


CLASS TTestFont
    DATA oFont
    DATA cFaceName
    DATA lBold
   
    METHOD New() CONSTRUCTOR
ENDCLASS


METHOD New() CLASS TTestFont
    OBJECT ::oFont AS TFont

        ::cFaceName = "Segoe UI Bold"
        ::lBold = .F.

    ENDOBJECT
RETURN Self
 


but then I got this error with FWH1905
Code: Select all  Expand view

Time from start: 0 hours 0 mins 0 secs
   Error occurred at: 06/19/19, 11:22:36
   Error description: Warning BASE/1005  Message not found: TFONT:_CVARNAME

Stack Calls
===========
   Called from: source\rtl\tobject.prg => TFONT:ERROR( 0 )
   Called from: source\rtl\tobject.prg => TFONT:MSGNOTFOUND( 0 )
   Called from: source\rtl\tobject.prg => TFONT:_CVARNAME( 0 )
   Called from: .\source\function\OBJECTS.PRG => SETOBJECT( 12 )
   Called from: _fontTests.prg => TTESTFONT:NEW( 33 )
   Called from: _fontTests.prg => MAIN( 17 )
 


Thank you again ;)
AnjaK
 
Posts: 6
Joined: Wed Jun 05, 2019 2:24 pm

Re: [BUG] in source/font.prg and a question

Postby nageswaragunupudi » Wed Jun 19, 2019 9:50 am

Please do not use those methods:

Please use these functions:

cText := FontToText( oFont ) // save this text anywhere

Later

oFont := FontFromText( cText )

Please try this and let us have your feed back.
Regards

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

Re: [BUG] in source/font.prg and a question

Postby AnjaK » Wed Jun 19, 2019 10:33 am

Thank you very much, that works like a charm ;)

But it is possible to create an object of
Code: Select all  Expand view

OBJECT ::oFont AS TFont

        ::cFaceName = "Segoe UI Bold"
        ::lBold = .F.

    ENDOBJECT
 


With
Code: Select all  Expand view

FUNCTION TestFont()
local Self

 OBJECT ::oFont AS TFont
        ::cFaceName = "Segoe UI Bold"
        ::lBold = .F.
 ENDOBJECT

RETURN Self
 


but you have to change the function SetObjet to
Code: Select all  Expand view

function SetObject( cVarName, bConstructor )

   local oSelf

   AAdd( aObjects, oSelf := Eval( bConstructor ) )
   if __ObjHasMsg( ATail( aObjects ), "cVarName" ) .and. ;
      __ObjHasMsg( aObjects[ 1 ], "_" + ATail( aObjects ):cVarName )
    oSelf:cVarName = cVarName

//      OSend( aObjects[ 1 ], "_" + ATail( aObjects ):cVarName, ATail( aObjects ) )
   endif


   if Len( aObjects ) == 1
      SetWndDefault( oSelf )
   endif

return oSelf
 

and use this together with the array aObjects and EndObject in the sample.

But that doens't help with SaveToText which I don't need ;)

Thank you again ;)
AnjaK
 
Posts: 6
Joined: Wed Jun 05, 2019 2:24 pm

Re: [BUG] in source/font.prg and a question

Postby ukoenig » Thu Jul 25, 2019 8:13 am

Why I'm getting this error trying to save a font

Code: Select all  Expand view

REDEFINE GET oCGet[4] VAR  aVal[6] ID 820 OF oFld:aDialogs[ 2 ] FONT oFontsys UPDATE ;
ACTION ( oFont0 :=  ChooseFont(), ;
                  IIF( !empty(oFont0), aVal[6] := FontToText( oFont0 ), NIL ), ;
          oCGet[4]:Refresh() )
 


A working solution
but why creating the font from array :?:

Code: Select all  Expand view

REDEFINE GET oCGet[4] VAR  aVal[6] ID 820 OF oFld:aDialogs[ 2 ] FONT oFontsys UPDATE ;
ACTION ( aFont :=  ChooseFont(), ;
                  oFont0 := BUILDFONT( aFont ), ;
                  IIF( !empty(oFont0), aVal[6] := FontToText( oFont0 ), NIL ), ;
          oCGet[4]:Refresh() )

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

STATIC FUNCTION BUILDFONT( aFont )

IF EMPTY( aFont[ LF_FACENAME ] )
        RETURN NIL
ENDIF

RETURN TFont():New( aFont[ LF_FACENAME ],;
   ,;
 aFont[ LF_HEIGHT ],;
    .f.,;
    !( aFont[ LF_WEIGHT ] == 400 ),;
    aFont[ LF_ESCAPEMENT ],;
    aFont[ LF_ORIENTATION ],;
    aFont[ LF_WEIGHT ],;
    aFont[ LF_ITALIC ],;
    aFont[ LF_UNDERLINE ],;
    aFont[ LF_STRIKEOUT ],;
    aFont[ LF_CHARSET ],;
    aFont[ LF_OUTPRECISION ],;
    aFont[ LF_CLIPPRECISION ],;
    aFont[ LF_QUALITY ],;
    ,;
    aFont[ LF_PITCHANDFAMILY ] )
 


To fill a empty var by default works

IF EMPTY( aVal[6] )
aVal[6] := FontToText( oFontSys )
ENDIF
IF EMPTY( aVal[7] )
aVal[7] := FontToText( oFontSys )
ENDIF
// oFont := FontFromText( aVal[7] ) test NO error


The errormessage

Time from start: 0 hours 0 mins 26 secs
Error occurred at: 25.07.2019, 10:06:16
Error description: Error BASE/1004 Class: 'ARRAY' has no exported method: CFACENAME
Args:
[ 1] = A { ... } length: 14

Stack Calls
===========
Called from: => CFACENAME( 0 )
Called from: .\source\classes\FONT.PRG => FONTTOTEXT( 641 )
Called from: .\ALARM.PRG => (b)PAGE2( 749 )
Called from: .\source\classes\TGET.PRG => (b)TGET:CREATEBUTTON( 952 )
Called from: .\source\classes\BUTTON.PRG => TBUTTONBMP:CLICK( 179 )

regards
Uwe :?:
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: [BUG] in source/font.prg and a question

Postby nageswaragunupudi » Thu Jul 25, 2019 9:35 am

ACTION ( oFont0 := ChooseFont(), ;
IIF( !empty(oFont0), aVal[6] := FontToText( oFont0 ), NIL ), ;
oCGet[4]:Refresh() )

Obviously this should give an error, because ChooseFont() returns an array, but not a font object and FontToText() works with font object not array.

This works
Code: Select all  Expand view

   oFont := TFont():New( nil, nil, nil, .t. )
   ? FontToText( oFont )
   oFont:End()
 
Regards

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

Re: [BUG] in source/font.prg and a question

Postby ukoenig » Thu Jul 25, 2019 9:43 am

Thank You very much for the info.

That means I can keep my working solution building the font from array
using < Choosefont >.
Maybe possible adding a parameter to < FontToText() > optional if to build
the text from array or from fontobject
or including maybe the existing function BUILDFONT( aFont ) :?:

----------------

I still have another question :

after
oFontMed1 := FontFromText( aVal[6] )
I must adjust the fontsize of the defined font in relation to the window-size and optional adding bold
I tested
oFontMed1:Modify( 50, .T. )
and
oFontMed1:nHeight(50)
but NO change :(

METHOD nWidth( nNewValue ) SETGET
METHOD nHeight( nNewValue ) SETGET
METHOD Modify( nHeight, lBold, lItalic, lUnderline, lStrikeOut, nEscapement )

regards
Uwe :D
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: [BUG] in source/font.prg and a question

Postby nageswaragunupudi » Thu Jul 25, 2019 10:43 am

Please read the methods again.

You need to use like this:
Code: Select all  Expand view

oBold := oFont:Bold()
// after usage
oBold:End()

oBigBold := oFont:Modify( -30, .t. )
// after usage
oBigBold:End()
 
Regards

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

Re: [BUG] in source/font.prg and a question

Postby nageswaragunupudi » Thu Jul 25, 2019 10:45 am

or including maybe the existing function BUILDFONT( aFont ) :?:

You can, If you like to duplicate the existing functionality.
Regards

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

Re: [BUG] in source/font.prg and a question

Postby ukoenig » Thu Jul 25, 2019 2:35 pm

Thank You very much.

It is working great now
I only have to select a font
the size is calculated in relation to the defined window-size

Image

The project I'm working on

A movable desktop-alarm on top of any app,
3 alarm-times can be defined
the window can be transparent or can have any color
square or rounded corners of the window
saves and restores the position of the window
3 windowsizes are possible
2 lines of alarm-reasons for each time can be defined
optional a alarm every day the same time or only the day / time
fontsizes are adjusted to the window-size
only the font no size-or bold-selection is needed
any fontsizes of time and date with any color
a sound can be selected for each alarm
TMPicker is rounded to minutes
and much more ...

regards
Uwe :D
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


Return to FiveWin for Harbour/xHarbour

Who is online

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

cron