Functions and Directives

Function GraSetFont() Foundation

Determines font for the display of characters drawn by GraStringAt().

GraSetFont( [<oPS>], [<oXbpFont>] ) --> oXbpCurrentFont
The argument <oPS> specifies the presentation space where the font is set. If the current window is an XbpCrt window, <oPS> is optional. If it is NIL, the return value of SetAppWindow():presSpace() is used. In all other cases <oPS> is not optional. It must be created either using XbpPresSpace():new() or a "Micro PS" must be requested from an Xbase Part using the method :lockPS(). After graphic output the Micro PS must be released with :unlockPS().
<oXbpFont> is a font object and determines the font for all characters drawn by GraStringAt(). A font object is made available through the class XbpFont (see XbpFont()).

The function GraSetFont() returns the font object currently set. If a new font is specified, the function returns the previous font object.


The function GraSetFont() determines the character font used for the graphic output of characters or character strings within a presentation space. A character font is made available by an XbpFont object (see XbpFont()). The function GraSetFont() installs a XbpFont object, which is then used for the display of characters by the function GraStringAt().

For the interactive selection of a font, Xbase++ provides a font dialog generated by the class XbpFontDialog().

Using the function GraSetAttrString(), the display of characters using a vector font can be modified in several ways.

Selecting and installing fonts

// The example program shows the selection of a font using the 
// font dialog. After the font was selected, it is installed with 
// GraSetFont() as the current font for the window. 

#include "" 
#include "" 

   LOCAL oFont, oFontDlg 

   oFontDlg := XbpFontDialog():New() 
   oFontDlg:Create()                 // create font dialog 

   SetMouse( .T. )                   // activate mouse 
   SetAppWindow():mouseMode := XBPCRT_MOUSEMODE_PM 
                                     // graphic mouse coordinates 
   SetColor( "N/W" )                 // fill window with pale gray 

   DO WHILE (oFont := oFontDlg:display(XBP_DISP_APPMODAL)) <> NIL 
                                     // modal font dialog 

      GraSetFont( NIL, oFont )       // install font 
      GraStringAt( NIL, {10,200}, ;  // output characters 
                  "The quick brown fox jumps over the lazy dog" ) 

      DO WHILE NextAppEvent() <> 0   // remove all events 
         AppEvent()                  // from the queue 
      AppEvent(,,,0)                 // wait for next event 

      oFontDlg:familyName := ;       // determine beginning 
         oFont:familyName            // element for combo box 

      CLS                            // fill window with pale gray 


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.