Creating a Custom Fill Pattern from a Font Character

The following figure is an example of how to create a custom fill pattern by using a character from a font. The fill pattern can be only an 8-by-8 bit map; as a result, not all of the character is used.

#define INCL_GPI
#define INCL_WIN
#include <os2.h>
   HPS hps;                      /* Presentation-space handle */
   LONG lcidCustom;              /* Font identifier           */
   FONTMETRICS afm[80];
   FATTRS fat;

   VOID LoadFont(VOID);

   void fncAREA05(void){

        LoadFont();
GpiSetPatternSet(hps, lcidCustom);
GpiSetPattern(hps, 'o');         /* Use lowercase 'o' as fill */
    .
    .
    .
   } /* fncAREA05 */

   VOID LoadFont(VOID){
      LONG cFonts = 0;
      LONG cPublicFonts, i;

      lcidCustom = 1;

/* Determine the number of loaded public fonts.               */
cPublicFonts = GpiQueryFonts(hps, QF_PUBLIC, NULL, (PLONG) &cFonts,
    (LONG) (sizeof(FONTMETRICS)), NULL);

/* Load the metrics for all public fonts into afm.            */
GpiQueryFonts(hps, QF_PUBLIC, NULL, (PLONG) &cPublicFonts,
    (LONG) (sizeof(FONTMETRICS)), afm);

/* Get the first image font with a point size larger than 8.  */
for (i = 0; ((afm[i].fsDefn & FM_DEFN_OUTLINE) ||
     afm[i].lEmHeight <= 8) && i < cPublicFonts; i++);

/* Load the FATTRS structure with the required metrics.       */
fat.usRecordLength = sizeof(fat);
fat.fsSelection = 0;
fat.lMatch = afm[i].lMatch;
StringCopy(fat.szFacename, afm[i].szFacename);
fat.idRegistry = 0;
fat.usCodePage = 0;
fat.lMaxBaselineExt = 0;
fat.lAveCharWidth = 0;
fat.fsType = 0;
fat.fsFontUse = 0;

/* Select this font and assign it a custom lcid.              */
GpiCreateLogFont(hps, NULL, lcidCustom, &fat);
GpiSetCharSet(hps, lcidCustom);
} /* LoadFont */


Creating a Custom Fill Pattern from a Font Character


[Back: Creating a Custom Fill Pattern from a Bit Map]
[Next: Bit Maps]