FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Choosing Printer Fonts
Posts: 274
Joined: Fri Apr 04, 2008 01:25 PM
Choosing Printer Fonts
Posted: Thu Nov 20, 2008 10:57 AM

Hi,

when calling the function "choosefont", the dialog-box for choosing fonts doesn't include installed printer fonts, but all TrueType fonts and system fonts are offered. Howerver, if I choose a font in Word, for example, these printer fonts are listed. Is there a way to let the user choose also from printer fonts?

Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
Posts: 274
Joined: Fri Apr 04, 2008 01:25 PM
Choosing Printer Fonts
Posted: Fri Nov 21, 2008 08:41 AM
If we call choosefont, compiled in 16-bit, the printer fonts are being displayed (2D-Code1 and 2D-Code2):


In the 32-bit compiled version, these fonts don't appear, although the same printer is chosen
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Choosing Printer Fonts
Posted: Fri Nov 21, 2008 09:20 AM
Gilbert,

In FWH\source\winapi\fonts.c function ChooseFont() we are using the flag: CF_SCREENFONTS

You may modify that source code to include this flag also: CF_PRINTERFONTS
   cf.Flags       = CF_SCREENFONTS | CF_PRINTERFONTS | IF( PCOUNT() > 1, CF_EFFECTS, 0 ) |
                    IF( bInitLF, CF_INITTOLOGFONTSTRUCT, 0 );
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 274
Joined: Fri Apr 04, 2008 01:25 PM
Choosing Printer Fonts
Posted: Fri Nov 21, 2008 11:10 AM
Antonio,

thanks for your help! However, the problem didn't happen with choosefont directly, but with oFont:Choose(). That was an error in my sourcecode research. But it seems to me there can be made an improvement to the Choose method in the TFont class, because the handle of the printer (hPrinterDC) isn't passed through to choosefont()

I made following modification:

   if nRGBColor != nil
      aFont := ChooseFont( { ::nInpHeight, ::nInpWidth, ::nEscapement,;
                             ::nOrientation, ::nWeight, ::lItalic,;
                             ::lUnderLine, ::lStrikeOut, ::nCharSet,;
                             ::nOutPrecision, ::nClipPrecision,;
                             ::nQuality, ::nPitchFamily, ::cFaceName },;
                             @nRGBColor )
   else
      aFont := ChooseFont( { ::nInpHeight, ::nInpWidth, ::nEscapement,;
                             ::nOrientation, ::nWeight, ::lItalic,;
                             ::lUnderLine, ::lStrikeOut, ::nCharSet,;
                             ::nOutPrecision, ::nClipPrecision,;
                             ::nQuality, ::nPitchFamily, ::cFaceName } )
   endif


to

	DO CASE
	CASE nRGBColor == nil .AND. hPrinterDC == nil
      aFont := ChooseFont( { ::nInpHeight, ::nInpWidth, ::nEscapement,;
                             ::nOrientation, ::nWeight, ::lItalic,;
                             ::lUnderLine, ::lStrikeOut, ::nCharSet,;
                             ::nOutPrecision, ::nClipPrecision,;
                             ::nQuality, ::nPitchFamily, ::cFaceName },;
                             )

	CASE nRGBColor == nil .AND. hPrinterDC != nil
      aFont := ChooseFont( { ::nInpHeight, ::nInpWidth, ::nEscapement,;
                             ::nOrientation, ::nWeight, ::lItalic,;
                             ::lUnderLine, ::lStrikeOut, ::nCharSet,;
                             ::nOutPrecision, ::nClipPrecision,;
                             ::nQuality, ::nPitchFamily, ::cFaceName },;
                             , hPrinterDC )

	CASE nRGBColor != nil .AND. hPrinterDC == nil
      aFont := ChooseFont( { ::nInpHeight, ::nInpWidth, ::nEscapement,;
                             ::nOrientation, ::nWeight, ::lItalic,;
                             ::lUnderLine, ::lStrikeOut, ::nCharSet,;
                             ::nOutPrecision, ::nClipPrecision,;
                             ::nQuality, ::nPitchFamily, ::cFaceName },;
                             @nRGBColor,  )

	CASE nRGBColor != nil .AND. hPrinterDC != nil
      aFont := ChooseFont( { ::nInpHeight, ::nInpWidth, ::nEscapement,;
                             ::nOrientation, ::nWeight, ::lItalic,;
                             ::lUnderLine, ::lStrikeOut, ::nCharSet,;
                             ::nOutPrecision, ::nClipPrecision,;
                             ::nQuality, ::nPitchFamily, ::cFaceName },;
                             @nRGBColor, hPrinterDC )

	ENDCASE


And now it works fine!
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Choosing Printer Fonts
Posted: Fri Nov 21, 2008 11:45 AM

Gilbert,

very good! :-)

Thanks for sharing your solution

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion