Graphics in C/C++: OUTTEXTXY and SETTEXTSTYLE functions with Example

In this tutorial, we are going to learn about the OUTTEXTXY and SETTEXTSTYLE functions with Example.
Submitted by Mahima Rao, on October 24, 2018

In today's advanced Advance Learning Tutorial, you will learn how to print any string in the graphics mode?


In the Graphics mode, if a function is given to print any string that is done using outtextxy.


    outtextxy (int x , int y , "Text");

Note: This function works only on the graphics mode.

int x and y denote the current position and it is in pixel form.


    outtextxy(10, 10, "Welcome to the Tutorial of Graphics");

The outtextxy character uses the current font, current direction, and current size.


The function setstextstyle() is used to set these three attributes of any text.


    settextstyle(int font , int direction , int charsize);

settextstyle sets font, direction and char size of the text.

Note: This function needs to be called before the outtextxy() function, otherwise there will be no effect on text and output will be the same.

Graphics system of C ++ supports 8x8 bitmapped font system.


It supports two types of directions:

  1. Horizontal text (left to right )
  2. Vertical text (right to left )

By default, the direction is the horizontal direction. For the horizontal direction, value zero (0) and the value one (1) is passed for the vertical direction.

Char Size:

This is also an integer value. You can extend the size of text up to 10 times. The starting value is 0 as if you increase the value, the font size will increase.


    outtextxy(150,180,"Welcome to the Tutorial of Graphics");

That's all for Learning Tutorial of Graphics in C/C++. If you have any problem in any of the topics mentioned above, then you can ask your questions in the comments section below.

Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.