This shows you the differences between two versions of the page.
— |
c:graphics.h:registerbgifont [2024/02/16 01:05] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== registerbgifont ===== | ||
+ | |||
+ | |||
+ | ====Syntax of registerbgifont ==== | ||
+ | <code c> | ||
+ | #include <graphics.h> | ||
+ | int registerbgifont(void (*font)(void)); | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ==== Description of registerbgifont ==== | ||
+ | <code c> | ||
+ | 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. | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ==== Example of registerbgifont ==== | ||
+ | <code c> | ||
+ | /* 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; | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ==== See also ==== | ||
+ | [[graphresult]] | ||
+ | [[initgraph]] | ||
+ | [[installuserdriver]] | ||
+ | [[registerbgidriver]] | ||
+ | [[settextstyle]] | ||
+ | |||
+ | |||
+ | ===== output of registerbgifont example ===== | ||
+ | |||
+ | no output of example at the moment | ||
+ | do not hesitate and add it... | ||
+ | |||
+ | |||