User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:graphics.h:registerbgifont

registerbgifont

Syntax of registerbgifont

#include <graphics.h>
int registerbgifont(void (*font)(void));
 

Description of registerbgifont

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.

Example of registerbgifont

/* 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;
}

See also

output of registerbgifont example

  no output of example at the moment
  do not hesitate and add it...  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/graphics.h/registerbgifont.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz