settextstyle function is used to set text style of given string. It modify the font style, direction of string and font size. It is used with outtext or outtextxy function. settextstyle function takes 3 input arguments namely font-style, direction(horizontal or vertical) and font size.
General syntax of settextstyle function is :
The following table shown the font style name and its corresponding int value.
#include <graphics.h>
#include <stdio.h>
int main( )
{
int gd=DETECT, gm;
char msg[]="Demonstration of settextstyle function";
initgraph(&gd,&gm,"C:\\tc\\bgi");
setbkcolor(8);
settextstyle(1,0,2);
outtextxy(200,130,"Programmingcampus.com");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3);
outtextxy(200,170,msg);
getch();
closegraph();
return 0;
}
General syntax of settextstyle function is :
settextstyle(int fontstyle, int direction, int char-size);
In settextstyle function we can choose font style by its int value or by font style name. And direction of text by int value( 0 or 1 ) or by direction name( HORIZ_DIR or VERT_DIR ).The following table shown the font style name and its corresponding int value.
Font Style Name | int value |
---|---|
DEFAULT_FONT | 0 |
TRIPLEX_FONT | 1 |
SMALL_FONT | 2 |
SANS_SERIF_FONT | 3 |
GOTHIC_FONT | 4 |
SCRIPT_FONT | 5 |
SIMPLEX_FONT | 6 |
TRIPLEX_SCR_FONT | 7 |
COMPLEX_FONT | 8 |
EUROPEAN_FONT | 9 |
BOLD_FONT | 10 |
C graphic program to demonstrate outtextxy function.
#include <graphics.h>
#include <stdio.h>
int main( )
{
int gd=DETECT, gm;
char msg[]="Demonstration of settextstyle function";
initgraph(&gd,&gm,"C:\\tc\\bgi");
setbkcolor(8);
settextstyle(1,0,2);
outtextxy(200,130,"Programmingcampus.com");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3);
outtextxy(200,170,msg);
getch();
closegraph();
return 0;
}
Download |
---|
0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.