Header file:
graphics.h
Synopsis:
void settextstyle(int font, int direction, int size);
Description:
settextstyle() sets the font style, direction and size.
settextstyle function in c graphics
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
int main(void) {
/* request auto detection */
int graphicDriver = DETECT, graphicMode;
int err, i;
char fonts[5][32] = {"DEFAULT_FONT", "TRIPLEX_FONT",
"SMALL_FONT", "SANS_SERIF_FONT",
"GOTHIC_FONT"};
/* initialize graphics and local variables */
initgraph(&graphicDriver, &graphicMode,
"C:/TURBOC3/BGI");
/* read result of initialization */
err = graphresult();
/* an error occurred */
if (err != grOk) {
printf("Graphic Error: %s\n",
grapherrormsg(err));
getch();
return 0;
}
for (i = 0; i < 5; i++) {
/* sets the current drawing color */
setcolor(i + 1);
/* setting text justification - horizontally & vertically */
settextjustify(CENTER_TEXT, CENTER_TEXT);
/* sets font style, direction and size */
settextstyle(i, i % 2, 5);
/* outputs given text at the given position */
outtextxy(getmaxx() / 2, getmaxy() / 2, fonts[i]);
/* sleep for 500 milliseconds */
delay(500);
/* clears graphic screen */
cleardevice();
}
/* clean up */
getch();
closegraph();
return 0;
}
Output: (settextstyle built-in function in c graphics.h)
No comments:
Post a Comment