SAMPLE: Corrections to the Windows 3.1 SDK Sample FONTEST

Last reviewed: June 16, 1997
Article ID: Q92538

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows version 3.1

SUMMARY

The FONTEST sample program in the Microsoft Software Library contains some corrections to problems that are in the version of the sample that shipped with the Windows 3.1 SDK.

MORE INFORMATION

In the original version of the sample, some of the values entered in the Set LogFont dialog box are mapped incorrectly to the underlying LOGFONT structure. The value entered for Italic is mapped into the LOGFONT's lfUnderline field and the value entered for Underline is mapped into the LOGFONT's lfItalic field. This causes an italic font to be created when an underline font is specified and an underline font to be created when an italic font is specified. The version of FONTEST in the Software Library corrects this problem.

When printing in the original version, if you choose a font from the Choose Font common dialog box, the output will be in a smaller size font than the output of the same font from another Windows-based application such as Microsoft Write.

The common dialog box function ChooseFont() always returns the height of the font in the lfHeight field of the LOGFONT structure based on the vertical dpi (dots per inch) of the screen. When creating a font to send to the printer, it is necessary to adjust the lfHeight field of the LOGFONT using the vertical dpi of the printer. To adjust the height, use the formula:

   Height = -(dpiY*point_size/72); //dpiY is dots per inch in Y direction

The FONTEST macro PT_TO_PIXELS in fontest.c performs the calculation to adjust the height of the LOGFONT. This adjusted height is passed into the FONTEST function PaintMetrics(), which creates a font and performs output. However, in the original version of FONTEST, the value for the adjusted height is not used. Because the dpi of most printers is greater than the dpi of the screen, the font that is created is smaller than it should be. The version of FONTEST in the Software Library uses the adjusted height value when creating the font.

This sample uses the Windows 3.1 common dialogs, so you must have the Windows 3.1 SDK to compile it.

Download FONTEST.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download FONTEST.EXE (size: 31997 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \SOFTLIB\MSLFILES directory
          Get FONTEST.EXE (size: 31997 bytes) 
    


Additional query words: softlib
Keywords : GdiFnt kbfile kbprg kbfile kbprg
Version : 3.1
Platform : WINDOWS
Resolution Type : kbfile


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.