Page 1 of 1

Problem with Choose font

Posted: Thu Apr 20, 2023 7:38 am
by Silvio.Falconi
When I recall Choosefont() I not see the font I select before
How I can to show the font I select before ?
I call with aFont := ChooseFont(,@nColorFont ) where nColorFont is the color

Re: Problem with Choose font

Posted: Thu Apr 20, 2023 11:26 pm
by cmsoft
Fijate si sirve asi:

Code: Select all | Expand

#include "FiveWin.ch"
function Main()

   local oWnd, oFont, oBtn, oGet, nColor := 0

   DEFINE DIALOG oWnd TITLE "Elegir font" 
   oFont:= oWnd:oFont

   @ 10,10 GET oGet VAR nColor PICTURE "999999999" RIGHT of oWnd PIXEL 

   @ 30,10 BUTTON oBtn PROMPT "Elegir Font" ACTION ElegirFont(@oFont,@nColor) OF oWnd SIZE 30,10 PIXEL

   ACTIVATE DIALOG oWnd 

return nil

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

function ElegirFont(oFont,nColor)

oFont := ChooseFont(oFont,@nColor)

return nil

Re: Problem with Choose font

Posted: Fri Apr 21, 2023 9:43 am
by Silvio.Falconi
I have different on my dialog I use BTNBMP control to show name of font and sizes

cFontName := oBrowse:aArraydata[nRecord][15]
nFontSize := oBrowse:aArraydata[nRecord][16]
lUnderline := oBrowse:aArraydata[nRecord][17]
lStrikeOut := oBrowse:aArraydata[nRecord][18]
lBold := oBrowse:aArraydata[nRecord][19]
lItalic := oBrowse:aArraydata[nRecord][20]
nColorFont := oBrowse:aArraydata[nRecord][21]


@ nRow,5 BTNBMP aGet[15] OF oDlg;
PROMPT cFontName RIGHT;
SIZE 250, 23 PIXEL FLAT NOROUND

@ nRow,215 BTNBMP aGet[16] OF oDlg;
PROMPT STR(nFontSize) LEFT;
SIZE 50, 23 PIXEL FLAT NOROUND



@ nRow, 255 BUTTONBMP oBtnSel[4] RESOURCE "REP_FONT" FLAT SIZE 20, 23 OF ooDlgPIXEL ;
ACTION (aFont := ChooseFont(@cFontName,@nColorFont ),;
cFontName:=aFont[LF_FACENAME],;
nFontSize:=IF( aFont[LF_HEIGHT ]!=NIL,FontHeightInPoints( aFont[LF_HEIGHT ]),0) ,;
lBold:= IIF(aFont[LF_WEIGHT]=700,.t.,.f.) ,;
lItalic:= aFont[LF_ITALIC],;
lUnderline:=aFont[LF_UNDERLINE],;
lStrikeout:=aFont[ LF_STRIKEOUT ],;
aGet[15]:settext(cFontName),;
aGet[16]:settext(str(nFontSize)),;
aGet[15]:refresh(),;
aGet[16]:refresh())


First run ok then On modify the choosefont not take the font I save before
I sent you a minitest

Re: Problem with Choose font

Posted: Fri Apr 21, 2023 4:40 pm
by Jimmy
hi Silvio,

as i understand the 1st Parameter is a Array or Object of used Font

Code: Select all | Expand

   aFont := ChooseFont( { oFont:nInpHeight, oFont:nInpWidth, oFont:nEscapement,;
                          oFont:nOrientation, oFont:nWeight, oFont:lItalic,;
                          oFont:lUnderLine, oFont:lStrikeOut, oFont:nCharSet,;
                          oFont:nOutPrecision, oFont:nClipPrecision,;
                          oFont:nQuality, oFont:nPitchFamily, oFont:cFaceName },;
                          @nNewColor )
later we can use Array aFont to create New Font

Code: Select all | Expand

   if !Empty( aFont[ LF_FACENAME ] )
      oNewFont = TFont():New( aFont[ LF_FACENAME ],, aFont[ LF_HEIGHT ], .f.,;
                           ! ( aFont[ LF_WEIGHT ] == FW_NORMAL ),;
                           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 ] )
and set new Color

Code: Select all | Expand

      o:SetFormat( oNewFont, nNewColor )

Re: Problem with Choose font

Posted: Mon Apr 24, 2023 7:21 pm
by Silvio.Falconi
Jimmy wrote:hi Silvio,

as i understand the 1st Parameter is a Array or Object of used Font

Code: Select all | Expand

   aFont := ChooseFont( { oFont:nInpHeight, oFont:nInpWidth, oFont:nEscapement,;
                          oFont:nOrientation, oFont:nWeight, oFont:lItalic,;
                          oFont:lUnderLine, oFont:lStrikeOut, oFont:nCharSet,;
                          oFont:nOutPrecision, oFont:nClipPrecision,;
                          oFont:nQuality, oFont:nPitchFamily, oFont:cFaceName },;
                          @nNewColor )
later we can use Array aFont to create New Font

Code: Select all | Expand

   if !Empty( aFont[ LF_FACENAME ] )
      oNewFont = TFont():New( aFont[ LF_FACENAME ],, aFont[ LF_HEIGHT ], .f.,;
                           ! ( aFont[ LF_WEIGHT ] == FW_NORMAL ),;
                           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 ] )
and set new Color

Code: Select all | Expand

      o:SetFormat( oNewFont, nNewColor )

Please help because it not run ok

I have the data in a browse

Code: Select all | Expand

    cFontName   := oBrowse:aArraydata[nRecord][15]
     nFontSize   := oBrowse:aArraydata[nRecord][16]
     lUnderline  := oBrowse:aArraydata[nRecord][17]
     lStrikeOut  := oBrowse:aArraydata[nRecord][18]
     lBold       := oBrowse:aArraydata[nRecord][19]
     lItalic     := oBrowse:aArraydata[nRecord][20]
     nColorFont  := oBrowse:aArraydata[nRecord][21]

 
only in the edit i create aFont array

aFont:= { , , ,, , lItalic,lUnderline, lStrikeOut, ,, ,, , cFontName }

then in the get control i do like this



Code: Select all | Expand


 @ nRow,5  BTNBMP aGet[15] OF oRigaModulo;
                PROMPT cFontName  RIGHT;
                SIZE 250, 23  PIXEL FLAT NOROUND

 @ nRow,215  BTNBMP aGet[16] OF oRigaModulo;
                PROMPT STR(nFontSize) LEFT;
                SIZE 50, 23  PIXEL FLAT NOROUND

@ nRow, 255 BUTTONBMP oBtnSel[4]  RESOURCE "REP_FONT"  FLAT SIZE 20, 23  OF oRigaModulo PIXEL ;
         ACTION (aFont  := ChooseFont(aFont,@nColorFont ),;
                           cFontName:=aFont[LF_FACENAME],;
         nFontSize:=IF( aFont[LF_HEIGHT ]!=NIL,FontHeightInPoints( aFont[LF_HEIGHT ]),0) ,;
                           lBold:= IIF(aFont[LF_WEIGHT]=700,.t.,.f.) ,;
                           lItalic:= aFont[LF_ITALIC],;
                           lUnderline:=aFont[LF_UNDERLINE],;
                           lStrikeout:=aFont[ LF_STRIKEOUT ],;
                           aGet[15]:settext(cFontName),;
                           aGet[16]:settext(str(nFontSize)),;
                           aGet[15]:refresh(),;
                           aGet[16]:refresh())

 

Re: Problem with Choose font

Posted: Wed Apr 26, 2023 11:03 pm
by Jimmy
hi Silvio,
Silvio.Falconi wrote:I have the data in a browse

Code: Select all | Expand

    cFontName   := oBrowse:aArraydata[nRecord][15]
     nFontSize   := oBrowse:aArraydata[nRecord][16]
     lUnderline  := oBrowse:aArraydata[nRecord][17]
     lStrikeOut  := oBrowse:aArraydata[nRecord][18]
     lBold       := oBrowse:aArraydata[nRecord][19]
     lItalic     := oBrowse:aArraydata[nRecord][20]
     nColorFont  := oBrowse:aArraydata[nRecord][21] 
only in the edit i create aFont array

Code: Select all | Expand

aFont:= { , , ,, , lItalic,lUnderline, lStrikeOut, ,, ,, , cFontName }
then in the get control i do like this
as i understand 1st Element is "Start-Point" so aFont must be "full filled" before pass it
but your aFont seems not to include "all"

Code: Select all | Expand

       aFont := { oFont:nInpHeight, oFont:nInpWidth, oFont:nEscapement,;
                              oFont:nOrientation, oFont:nWeight, oFont:lItalic,;
                              oFont:lUnderLine, oFont:lStrikeOut, oFont:nCharSet,;
                              oFont:nOutPrecision, oFont:nClipPrecision,;
                              oFont:nQuality, oFont:nPitchFamily, oFont:cFaceName }
i do have a oFont Object which also can be passed as 1st Parameter