i want to change some definitions of a font after creation.
DEFINE FONT oFont NAME "Times New Roman" SIZE 10, 12 OF oPrn
i have tried this, but doesn't work:
oFont:nWidth( 24 ); oFont:nHeight( 10 )
oFont:lBold := .t.
oFont:lItalic := .t.
oFont:cFaceName := "Arial"
is it possible?
thanks, marzio
change font after creation
- Otto
- Posts: 6416
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 35 times
- Been thanked: 2 times
- Contact:
Re: change font after creation
Best regards,
Otto
FIVEWIN samples: testfon3.prg
Otto
FIVEWIN samples: testfon3.prg
Code: Select all | Expand
// Saving and restoring a font. By Enrico Maria Giordano
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oWnd
LOCAL cVar := "This is a test"
LOCAL aFont := SELECTFONT( oWnd )
LOCAL aSaved
IF EMPTY( aFont ); RETURN NIL; ENDIF
DEFINE WINDOW oWnd
@ 1, 1 SAY "This is a test";
COLOR CLR_BLACK
@ 3, 1 GET cVar;
SIZE 100, 20
@ 5, 1 BUTTON "Choose font";
SIZE 100, 20;
ACTION aFont := SELECTFONT( oWnd )
@ 7, 1 BUTTON "Save font";
SIZE 100, 20;
ACTION aSaved := aFont
@ 9, 1 BUTTON "Restore font";
SIZE 100, 20;
ACTION RESTOREFONT( oWnd, aSaved )
ACTIVATE WINDOW oWnd
RETURN NIL
#define FW_NORMAL 400
STATIC FUNCTION SELECTFONT( oWnd )
LOCAL aFont := CHOOSEFONT()
LOCAL oFont := BUILDFONT( aFont )
IF oFont = NIL; RETURN NIL; ENDIF
IF oWnd != NIL; REFRESHWND( oWnd, oFont ); ENDIF
RETURN aFont
STATIC FUNCTION RESTOREFONT( oWnd, aFont )
LOCAL oFont := BUILDFONT( aFont )
IF oFont = NIL; RETURN NIL; ENDIF
REFRESHWND( oWnd, oFont )
RETURN NIL
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 ] == 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 ] )
STATIC FUNCTION REFRESHWND( oWnd, oFont )
LOCAL i
oWnd:SetFont( oFont )
FOR i = 1 TO LEN( oWnd:aControls )
oWnd:aControls[ i ]:SetFont( oFont )
oWnd:aControls[ i ]:Refresh()
NEXT
RETURN NIL
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- nageswaragunupudi
- Posts: 10733
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 11 times
- Contact:
Re: change font after creation
We can not change the font attributes of the same font object after definition. But we can derive a new font object with changing some attributes and set the new font to the control. In many cases it is much easier than the method suggested in testfon3.prg.
Examples:
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
oBold := oFont:Bold( .t. )
oBoldItalic := oBold:Italic( .t. )
Methods available are :
METHOD Bold( lOnOff )
METHOD Italic( lOnOff )
METHOD Underline( lOnOff )
METHOD StrikeOut( lOnOff )
METHOD Escapement( nEsc )
METHOD Rotate( n )
METHOD Modify( nHeight, lBold, lItalic, lUnderline, lStrikeOut, nEscapement )
Examples:
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
oBold := oFont:Bold( .t. )
oBoldItalic := oBold:Italic( .t. )
Methods available are :
METHOD Bold( lOnOff )
METHOD Italic( lOnOff )
METHOD Underline( lOnOff )
METHOD StrikeOut( lOnOff )
METHOD Escapement( nEsc )
METHOD Rotate( n )
METHOD Modify( nHeight, lBold, lItalic, lUnderline, lStrikeOut, nEscapement )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: change font after creation
thanks for your replays.
i have many line like these,
for each line that i print i have to change the dimension of the font:
DEFINE FONT oFont NAME "Times New Roman" SIZE 24, 13 OF oPrn
oPrn:Say(..., oFont)
oFont:End()
DEFINE FONT oFont NAME "Times New Roman" SIZE 15, 9 OF oPrn
oPrn:Say(..., oFont)
etc. many times
in the class tfont there are 2 function:
METHOD nWidth( nNewValue ) SETGET
METHOD nHeight( nNewValue ) SETGET
oFont:nWidth( 15 ); oFont:nHeight( 9 )
but this doesn't work.
oFont:End() with the definition of a new font is the best solution?
regards, marzio
i have many line like these,
for each line that i print i have to change the dimension of the font:
DEFINE FONT oFont NAME "Times New Roman" SIZE 24, 13 OF oPrn
oPrn:Say(..., oFont)
oFont:End()
DEFINE FONT oFont NAME "Times New Roman" SIZE 15, 9 OF oPrn
oPrn:Say(..., oFont)
etc. many times
in the class tfont there are 2 function:
METHOD nWidth( nNewValue ) SETGET
METHOD nHeight( nNewValue ) SETGET
oFont:nWidth( 15 ); oFont:nHeight( 9 )
but this doesn't work.
oFont:End() with the definition of a new font is the best solution?
regards, marzio
Re: change font after creation
Not easy, but possible
Font-Editor Update Rel. 1.3
New Background-Color added
New Font-Style Browser added
New Underline added
Changed Text-Size Range 10 - 60

Download :
http://www.pflegeplus.com/fw_downloads/fontedit3.zip
Best Regards
Uwe
Font-Editor Update Rel. 1.3
New Background-Color added
New Font-Style Browser added
New Underline added
Changed Text-Size Range 10 - 60

Download :
http://www.pflegeplus.com/fw_downloads/fontedit3.zip
Best 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.
i work with FW.
If you have any questions about special functions, maybe i can help.