home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / PMFONT.ZIP / FNTS.C next >
Text File  |  1991-06-27  |  1KB  |  48 lines

  1. #define INCL_DEV
  2. #define INCL_DOSMEMMGR
  3. #define INCL_GPILCIDS
  4. #define INCL_WINWINDOWMGR
  5. #define INCL_WINLISTBOXES
  6. #include <os2.h>
  7. #include <stdio.h>
  8.  
  9. VOID EXPENTRY FntQueryList(hwnd)
  10. HWND hwnd; // listbox handle
  11.   {
  12.   PFONTMETRICS pfm;
  13.   HDC          hdc;
  14.   HPS          hps;
  15.   LONG         alDevInfo[2];
  16.   LONG         lFonts;
  17.   LONG         lFontCnt = 0L;
  18.   CHAR         pch[64];
  19.   SEL          sel;
  20.   USHORT       i;
  21.  
  22.   hdc = WinOpenWindowDC(hwnd);
  23.   DevQueryCaps(hdc, CAPS_HORIZONTAL_FONT_RES, 2L, alDevInfo);
  24.   hps = WinGetPS(hwnd);
  25.   lFonts = GpiQueryFonts(hps, QF_PUBLIC, (PSZ)0, &lFontCnt,
  26.                          (LONG)sizeof(FONTMETRICS), (PFONTMETRICS)0 );
  27.   DosAllocSeg((USHORT)lFonts * sizeof(FONTMETRICS), &sel, SEG_NONSHARED);
  28.   pfm = (PFONTMETRICS)MAKEP(sel, 0);
  29.   GpiQueryFonts(hps, QF_PUBLIC, (PSZ)0, &lFonts,
  30.                 (LONG)sizeof(FONTMETRICS), pfm );
  31.   for (i = 0; i < (USHORT)lFonts; i++) {
  32.     if (!(pfm[i].fsDefn & FM_DEFN_OUTLINE)) {
  33.       if ((pfm[i].sXDeviceRes == (SHORT)alDevInfo[0]) &&
  34.           (pfm[i].sYDeviceRes == (SHORT)alDevInfo[1]) ) {
  35.         sprintf(pch,
  36.                 "%2d.%s",
  37.                 pfm[i].sNominalPointSize / 10,
  38.                 pfm[i].szFacename );
  39.         WinSendMsg(hwnd, LM_INSERTITEM,
  40.                    MPFROMSHORT(LIT_END), MPFROMP(pch) );
  41.         }
  42.       }
  43.     }
  44.   DosFreeSeg(sel);
  45.   WinReleasePS(hps);
  46.   return;
  47.   }
  48.