registerbgifont
- Syntax
-
#include <graphics.h> int registerbgifont(void (*font)(void));
- Description
-
Calling registerbgifont informs the graphics system that the font
pointed to by font was included at link time. This routine checks the
linked-in code for the specified font; if the code is valid, it
registers the code in internal tables.
By using the name of a linked-in font in a call to registerbgifont, you also tell the compiler (and linker) to link in the object file with that public name.
If you register a user-supplied font, you must pass the result of registerbgifont to settextstyle as the font number to be used.
- Return Value
- registerbgifont returns a negative graphics error code if the specified font is invalid. Otherwise, registerbgifont returns the font number of the registered font.
- Windows Notes
![[WIN]](http://users.atw.hu/laciba/app_help/cpp/bgi/win.gif)
- registerbgifont is not available in the winbgim implementation.
- See also
- graphresult
- initgraph
- installuserdriver
- registerbgidriver
- settextstyle
- initgraph
- Example
-
/* registerbgifont example */ #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> int main(void) { /* request autodetection */ int gdriver = DETECT, gmode, errorcode; int midx, midy; /* register a font file that was added into GRAPHICS.LIB */ errorcode = registerbgifont(triplex_font); /* report any registration errors */ if (errorcode < 0) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) { /* an error occurred */ printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ } midx = getmaxx() / 2; midy = getmaxy() / 2; /* select the registered font */ settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4); /* output some text */ settextjustify(CENTER_TEXT, CENTER_TEXT); outtextxy(midx, midy, "The TRIPLEX FONT"); /* clean up */ getch(); closegraph(); return 0; }
Back to index
