Jump to content

GpiLoadPublicFonts

From EDM2

This function loads one or more fonts from the specified resource file, to be available for all applications.

Syntax

GpiLoadPublicFonts(hab, pszFilename)

Parameters

hab (HAB) - input
Anchor-block handle.
pszFilename (PSZ) - input
Filename.
This is the fully-qualified name of the font resource. The file-name extension is ".FON".

Return Value

rc (BOOL) - returns
Success indicator.
TRUE
Successful completion
FALSE
Error occurred.

Remarks

All of the fonts in the file become available for any presentation space (GPI or VIO) created by any process.

The format of the font definitions in the resource file is defined in Font-File Format.

Note: Problems can occur when applications load and unload public fonts. See GpiUnloadPublicFonts.

Errors

Possible returns from WinGetLastError:

PMERR_INSUFFICIENT_MEMORY (0x203E)
The operation terminated through insufficient memory.
PMERR_INV_FONT_FILE_DATA (0x2073)
The font file specified with GpiLoadFonts, GpiLoadPublicFonts, GpiQueryFontFileDescriptions, or GpiQueryFullFontFileDescs contains invalid data.

Example Code

#define INCL_GPILCIDS /* Or use INCL_GPI, INCL_PM, */
#include <os2.h>

HAB hab;         /* Anchor-block handle. */
PSZ pszFilename; /* Filename. */
BOOL rc;         /* Success indicator. */

rc = GpiLoadPublicFonts(hab, pszFilename);

This example use GpiLoadPublicFonts to load and make available fonts from a file "TEST.FON", which is assumed to exist in the root directory of the C: drive and is assumed to contain valid fonts.

#define INCL_GPILCIDS /* Font functions */
#include <os2.h>

BOOL fSuccess; /* success indicator */
HAB hab; /* anchor-block handle */
char pszFilename[16]; /* Name of font resource file */

/* Resource file is named 'TEST.FON' */
strcpy(pszFilename,"C:\\TEST.FON");

fSuccess = GpiLoadPublicFonts(hab, pszFilename);