You are here

Settextstyle function in c

Settextstyle function is used to change the way in which text appears, using it we can modify the size of text, change direction of text and change the font of text.

Declaration: void settextstyle( int font, int direction, int charsize);
font argument specifies the font of text, Direction can be HORIZ_DIR (Left to right) or VERT_DIR (Bottom to top).

Different fonts

enum font_names
{
   DEFAULT_FONT,
   TRIPLEX_FONT,
   SMALL_FONT,
   SANS_SERIF_FONT,
   GOTHIC_FONT,
   SCRIPT_FONT,
   SIMPLEX_FONT,
   TRIPLEX_SCR_FONT,
   COMPLEX_FONT,
   EUROPEAN_FONT,
   BOLD_FONT
};

C programming source code for settextstyle

#include <graphics.h>
#include <conio.h>
 
main()
{
   int gd = DETECT, gm, x = 25, y = 25, font = 0;
   
   initgraph(&gd,&gm,"C:\\TC\\BGI");
 
   for (font = 0; font <= 10; font++)
   {
      settextstyle(font, HORIZ_DIR, 1);
      outtextxy(x, y, "Text with different fonts");
      y = y + 25;
   }
 
   getch();
   closegraph();
   return 0;
}