gpi12.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
GpiCreateLogFont (1.2)
Function Group  Overview  Changes               Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_GPILCIDS
 
LONG GpiCreateLogFont(hps, pchName, lcid, pfat)
HPS hps;          /* presentation-space handle                */
PSTR8 pchName;    /* address of logical-font name             */
LONG lcid;        /* local identifier                         */
PFATTRS pfat;     /* address of structure for font attributes */
 
The GpiCreateLogFont function creates a logical font. A logical font is a
list of font attributes, such as face name, average width, and maximum
height, that an application uses to request a physical font. A physical font
is the bitmap or vector information the system uses to draw characters on a
device. Applications create logical fonts to specify the fonts they need,
and the system maps the logical fonts to matching physical fonts.
 
GpiCreateLogFont creates a logical font using the font attributes specified
in the structure pointed to by the pfat parameter. Each logical font has a
local identifier and logical font name, specified by the lcid and pchName
parameters, to uniquely identify it. The local identifier can then be used
in subsequent graphics functions to identify the font.
 
Since a physical font that exactly matches the logical font may not be
available, the system usually maps the logical font to the closest matching
physical font. The system uses rules to map the font──for example, it
chooses a font with a greater height if a font of the exact height is not
available. An application can force the system to choose a particular font
by setting the value of the lMatch field in the FATTRS structure to be that
returned for the desired font by the GpiQueryFonts function. After
GpiCreateLogFont chooses the physical font, this choice does not change for
a particular logical font.
 
Parameter  Description
────────────────────────────────────────────────────────────────────────────
 
hps        Identifies the presentation space.
 
pchName    Points to an 8-character logical-font name. It can be NULL, if no
           logical font name is desired.
 
lcid       Specifies the local identifier that the application uses to refer
           to this font. It must be in the range 1 through 254. It is an
           error if this parameter is already in use to refer to a font or
           bitmap.
 
pfat       Points to a FATTRS structure that will contain the attributes of
           the logical font that is created.
 
Return Value
 
The return value is FONT_MATCH if a matching font is found, FONT_DEFAULT if
a matching font could not be found, or zero if an error occurred.
 
Errors
 
Use the WinGetLastError function to retrieve the error value, which may be
one of the following:
 
     PMERR_FONT_NOT_LOADED
     PMERR_INV_FONT_ATTRS
     PMERR_INV_HPS
     PMERR_INV_SETID
     PMERR_KERNING_NOT_SUPPORTED
     PMERR_PS_BUSY
     PMERR_SETID_IN_USE
 
Comments
 
To choose the system default font, set the face name to NULL and all other
attributes in the FATTRS structure, except the code page, to zero.
 
To use a font, the application sets the font for the presentation space by
specifying the local identifier for the corresponding logical font with the
GpiSetCharSet function. Once a font is set, the system uses the font for
subsequent text output.
 
Example
 
This example uses the GpiCreateLogFont function to create a logical font
with the local identifier 1. The logical font has the face name "Courier"
and requested width and height of 12 pels. Once the font is created, the
example sets the font using the local identifier and displays a string in
the font at the point (100,100).
 
USHORT i;
POINTL ptl = { 100, 100 };
FATTRS fat;
 
fat.usRecordLength = sizeof(FATTRS); /* sets size of structure      */
fat.fsSelection = 0;            /* uses default selection           */
fat.lMatch = 0L;                /* does not force match             */
fat.idRegistry = 0;             /* uses default registry            */
fat.usCodePage = 850;           /* code-page 850                    */
fat.lMaxBaselineExt = 12L;      /* requested font height is 12 pels */
fat.lAveCharWidth = 12L;        /* requested font width is 12 pels  */
fat.fsType = 0;                 /* uses default type                */
fat.fsFontUse = FATTR_FONTUSE_NOMIX; /* does not mix with graphics  */
 
/* Copy Courier to szFacename field. */
 
for (i=0; fat.szFacename[i] = "Courier"[i]; i++);
 
GpiCreateLogFont(hps,           /* presentation space               */
                 (PSTR8) NULL,  /* does not use logical font name   */
                 1L,            /* local identifier                 */
                 &fat);         /* structure with font attributes   */
 
GpiSetCharSet(hps, 1L);         /* sets font for presentation space */
GpiCharStringAt(hps, &ptl, 5L, "Hello"); /* displays a string       */
 
See Also
 
GpiCharStringAt, GpiCreateLogFont, GpiQueryFonts, GpiSetCharSet,
WinGetLastError, FATTRS