home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol12n08.zip / OLFDEM.ZIP / OLFLIST.C < prev    next >
C/C++ Source or Header  |  1993-02-05  |  2KB  |  77 lines

  1. /*----------------------------------------
  2.    OLFLIST.C -- Lists OS/2 Outline Fonts
  3.                 (c) Charles Petzold, 1993
  4.   ----------------------------------------*/
  5.  
  6. #define INCL_WIN
  7. #define INCL_GPI
  8. #include <os2.h>
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include "olf.h"
  12.  
  13. #define LCID_FONT     1
  14. #define PTSIZE      120
  15. #define PTWIDTH     120
  16.  
  17. void PaintClient (HPS hps, SHORT cxClient, SHORT cyClient)
  18.      {
  19.      CHAR         szBuffer [FACESIZE + 32] ;
  20.      FONTMETRICS  fm ;
  21.      int          i ;
  22.      PFACELIST    pfl ;
  23.      POINTL       ptl ;
  24.  
  25.           // Get pointer to FACELIST structure
  26.  
  27.      pfl = GetAllOutlineFonts (hps) ;
  28.  
  29.           // Set POINTL structure to upper left corner of client
  30.  
  31.      ptl.x = 0 ;
  32.      ptl.y = cyClient ;
  33.  
  34.           // Loop through all the outline fonts
  35.  
  36.      for (i = 0 ; i < pfl->iNumFaces ; i++)
  37.           {
  38.                // Create the logical font and select it
  39.  
  40.           CreateOutlineFont (hps, LCID_FONT, pfl->szFacename[i], 0, 0) ;
  41.           GpiSetCharSet (hps, LCID_FONT) ;
  42.  
  43.                // Scale the selected font
  44.  
  45.           ScaleOutlineFont (hps, PTSIZE, PTWIDTH) ;
  46.  
  47.                // Query the font metrics of the current font
  48.  
  49.           GpiQueryFontMetrics (hps, sizeof (FONTMETRICS), &fm) ;
  50.  
  51.                // Set up a text string to display
  52.  
  53.           sprintf (szBuffer, "%s - %d decipoints, width %d",
  54.                    fm.szFacename, PTSIZE, PTWIDTH) ;
  55.  
  56.                // Drop POINTL structure to baseline of font
  57.  
  58.           ptl.y -= fm.lMaxAscender ;
  59.  
  60.                // Display the character string
  61.  
  62.           GpiCharStringAt (hps, &ptl, strlen (szBuffer), szBuffer) ;
  63.  
  64.                // Drop POINTL structure down to bottom of text
  65.  
  66.           ptl.y -= fm.lMaxDescender ;
  67.  
  68.                // Select the default font; delete the logical font
  69.  
  70.           GpiSetCharSet (hps, LCID_DEFAULT) ;
  71.           GpiDeleteSetId (hps, LCID_FONT) ;
  72.  
  73.           if (ptl.y < 0)
  74.                break ;
  75.           }
  76.      }
  77.