## Presentation Device Driver Reference for OS/2

[prev][next][parent][TOC]

### GreRealizeFont - Remarks

GreRealizeFont is called by the graphics engine to allow the presentation driver to satisfy logical font requests. The example below shows a typical font-matching algorithm for the presentation driver:

    /* If the face name is empty, the application is requesting the default font.  Return NO_MATCH.*/

       if(Font->szFacename = NULL)

       {

          return(0);

       }

    /* If the match number is positive, an engine font is required.  Return NO_MATCH.              */

       if(Font->lfMatch > 0)

       {

          return(0);

       }

    /* If the match number is negative, a device font is required.  The presentation driver should  */

    /* return the font if it exists; otherwise return NO_MATCH.                                     */

       if(Font->lMatch < 0)

       {

         if(font with required lMatch exists)

         {

         /* Check the fsSelection flags and szFacename.  If the font is unable to satisfy these     */

         /* flags, return NO_MATCH.  Otherwise, return the device font handle.                      */

           if((FATTR_FONTUSE_OUTLINE && font not outline)

             ||(FATTR_FONTUSE_TRANSFORMABLE && font not outline) ||(szFacename does not match font))

              return(0);

           else

              return(device_font_handle);

         }

         else

         {

         /* Attempt metrics match (i.e. all metrics including szFaceName, usCodePage, lAveCharWidth */

         /* and lMaxBaselineExt).  If match exists, return device font handle.  Otherwise, return   */

         /* NO_MATCH.                                                                               */

           if(metric match exists)

           {

              return(device_font_handle);

           }

           else

              return(0);

         }

       }

    /* The match number is zero, the presentation driver should search for a font with the          */

    /* specified metrics, and if an exact match exists, return the device font handle. Otherwise,   */

    /* return NO_MATCH.                                                                             */

    if(Font->lMatch = 0)

    {

      if(metrics match exists - see above)

      {

      /* Check the fsSelection flags.  If the font is unable to satisfy these flags, return          */

      /* NO_MATCH.  Otherwise, return the device font handle.                                        */

        if((FATTR_FONTUSE_OUTLINE && font not outline)

        ||(FATTR_FONTUSE_TRANSFORMABLE && font not outline)

           return(0);

        else

           return(device_font_handle);

      }

    else

       return(0);

    }

Graphics Engine Simulation

1.The GRE calls GreRealizeFont with cmdCommand equal to RF_DEVICE_FONT if the driver returns 0.

2.The GRE calls again with cmdCommand == RF_LOAD_ENGINE_FONT and the pFont parameter points to a FOCAFONT structure.

3.If the fsDefn field for the font has FM_DEFN_GENERIC and the driver does not report that it is CAPS_RASTER for the GreQueryDeviceCaps() entry point, the FOCAFONT will be followed by the character glyphs as documented in the Presentation Manager Programming Reference, Volume 3.

4.Subsequent GreDeviceSetAttributes() calls will have the CDEF_GENERIC flag turned off for the font.