C语言中的settextstyle函数

头文件显示图形。h包含 settextstyle() 用于更改文本显示方式的函数。使用它我们可以修改文本的大小,改变文本的方向,改变文本的字体。 语法:

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

例如:

Input : font = 8, direction = 0, font_size = 5Output : 

图片[1]-C语言中的settextstyle函数-yiteyi-C++库

Input : font = 3, direction = 0, font_size = 5Output : 

图片[2]-C语言中的settextstyle函数-yiteyi-C++库

下表显示了字体及其INT值和外观:

图片[3]-C语言中的settextstyle函数-yiteyi-C++库

下面是settextstyle()函数的实现:

CPP

// C++ implementation for
// settextstyle() function
#include <graphics.h>
// driver code
int main()
{
// gm is Graphics mode which is
// a computer display mode that
// generates image using pixels.
// DETECT is a macro defined in
// "graphics.h" header file
int gd = DETECT, gm;
// initgraph initializes the
// graphics system by loading
// a graphics driver from disk
initgraph(&gd, &gm, "" );
// location of text
int x = 150;
int y = 150;
// font style
int font = 8;
// font direction
int direction = 0;
// font size
int font_size = 5;
// for setting text style
settextstyle(font, direction, font_size);
// for printing text in graphics window
outtextxy(x, y, "Geeks For Geeks" );
getch();
// closegraph function closes the
// graphics mode and deallocates
// all memory allocated by graphics
// system .
closegraph();
return 0;
}


输出:

图片[4]-C语言中的settextstyle函数-yiteyi-C++库

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享