📜  C语言中的settextstyle函数

📅  最后修改于: 2021-05-25 21:02:37             🧑  作者: Mango

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

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).

例子 :

输入:字体= 8,方向= 0,字体大小= 5输出: 输入:字体= 3,方向= 0,字体大小= 5输出:

下表显示了字体值及其INT值。

COLOR               INT VALUES
-------------------------------
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

下面是settextstyle()函数:

// C++ implementation for
// settextstyle() function
#include 
  
// 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;
}

输出:

想要从精选的最佳视频中学习和练习问题,请查看《基础知识到高级C的C基础课程》。