Choosing Printer Fonts

Choosing Printer Fonts

Postby gkuhnert » 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
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Postby gkuhnert » Fri Nov 21, 2008 8:41 am

If we call choosefont, compiled in 16-bit, the printer fonts are being displayed (2D-Code1 and 2D-Code2):
Image

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

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Postby Antonio Linares » Fri Nov 21, 2008 9: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
Code: Select all  Expand view
   cf.Flags       = CF_SCREENFONTS | CF_PRINTERFONTS | IF( PCOUNT() > 1, CF_EFFECTS, 0 ) |
                    IF( bInitLF, CF_INITTOLOGFONTSTRUCT, 0 );
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby gkuhnert » 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:

Code: Select all  Expand view
   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

Code: Select all  Expand view
   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
User avatar
gkuhnert
 
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands

Postby Antonio Linares » Fri Nov 21, 2008 11:45 am

Gilbert,

very good! :-)

Thanks for sharing your solution
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests