BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/index.php)
-   Object Oriented Programming (http://bzupages.com/forumdisplay.php?f=322)
-   -   Program to write in different fonts on the screen (http://bzupages.com/showthread.php?t=14567)

bonfire 01-03-2011 03:02 PM

Program to write in different fonts on the screen
 
1 Attachment(s)
Program to write in different fonts on the screen


#include
#include
#include
#include

void main (int)
{
int gdriver=DETECT,gmode,errorcode; //Requesting auto-detection.
int midx,midy,fstyle;
//Initializing graphics and local variables.
initgraph(&gdriver,&gmode,"d:\\bc3\\bgi");
//Reading result of initialization.
errorcode=graphresult();
if(errorcode!=grOk)
//An error occurred.
{
printf("Graphics error occurred : %s \n",grapherrormsg(errorcode));
printf("Press any key to stop : ");
getch();
exit(1); //Terminate the program due to error.
}
//Changing the font styles using a loop.
cleardevice();
settextstyle(DEFAULT_FONT,HORIZ_DIR,4);
/*The above statement means that it is the default font in the horizontal
direction and the font size is 4.*/
//Outputting a message.
outtextxy(200,200,"Default font");
getch();
cleardevice();
settextstyle(TRIPLEX_FONT,VERT_DIR,5);
/*The above statement means that it is the triplex font in the vertical
direction and the font size is 5.*/
//Outputting a message.
outtextxy(200,200,"Triplex font");
getch();
cleardevice();
settextstyle(GOTHIC_FONT,HORIZ_DIR,5);
/*The above statement means that it is the default font in the horizontal
direction and the font size is 2.*/
//Outputting a message.
outtextxy(200,200,"Gothic font");
getch();
cleardevice();
settextstyle(SMALL_FONT,VERT_DIR,5);
/*The above statement means that it is the small font in the vertical
direction and the font size is 5.*/
//Outputting a message.
outtextxy(200,200,"Small font");
getch();
cleardevice();
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,5);
/*The above statement means that it is the sans serif font in the horizontal
direction and the font size is 5.*/
//Outputting a message.
outtextxy(200,200,"Sans Serif font");
getch();
closegraph();
}
This graphics program switches between default font, triplex font, gothic font, small font and sans serif font using the 'settextstyle' command.


All times are GMT +5. The time now is 02:15 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.