The header file graphics.h contains settextstyle() function which 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.
Syntax :
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).
Examples :
Input : font = 8, direction = 0, font_size = 5 Output :Input : font = 3, direction = 0, font_size = 5 Output :
![]()
The table below shows the fonts value with their INT values.
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
Below is the implementation of settextstyle() function :
// 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; } |
Output:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- How to call function within function in C or C++
- Write a one line C function to round floating point numbers
- Does C support function overloading?
- How can I return multiple values from a function?
- What is the purpose of a function prototype?
- How to declare a pointer to a function?
- C function to Swap strings
- Can we call an undeclared function in C++?
- What is evaluation order of function parameters in C?
- Can we use function on left side of an expression in C and C++?
- Function Pointer in C
- Importance of function prototype in C
- What happens when a function is called before its declaration in C?
- Default arguments and virtual function
- Function overloading and const keyword
- How to measure time taken by a function in C?
- Comparator function of qsort() in C
- Can we access private data members of a class without using a member or a friend function?
- Print substring of a given string without using any string function and loop in C
- How to print range of basic data types without any library function and constant in C?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Hax4us


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