---
name: "dtk_create_string"
section: "3"
platform: "linux"
package: "libdrawtk-dev"
version: "2.0-2.1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/dtk_create_string"
---

# dtk\_create\_string(3)

Creates or modify a shape to display a string

## NAME

dtk\_create\_string - Creates or modify a shape to display a string

## SYNOPSIS

**#include \<drawtk.h\>**

**dtk\_hshape dtk\_create\_string(dtk\_hshape** *shp***, const char \****text***,**\
                              **float** *size***, float** *x***, float** *y***,**\
                              **unsigned int** *alignment***,**\
                              **const float \****color***, dtk\_hfont** *font***);**\

## DESCRIPTION

**dtk\_create\_string**() creates a text specified by *text* at location (*x*,*y*) with a font size of *size* using a previously loaded font referenced by *font* argument (see [**dtk\_load\_font**(3)](/dtk_load_font/3.md)).

The position (*x*,*y*) is interpreted according to the combination of flags controlling the vertical and horizontal alignment defined in the *alignment* argument:

- \*

  **DTK\_BOTTOM**, **DTK\_VMID** and **DTK\_TOP** make the value *y* to be interpreted as respectively the bottom, the middle and the top of the bounding box of the shape.

- \*

  **DTK\_LEFT**, **DTK\_HMID** and **DTK\_RIGHT** make the value *x* to be interpreted as respectively the left, the middle and the right of the bounding box of the shape.

*shp* and *color* has the same usage and meaning than in other shape creation functions (see [**dtk\_create\_shape**(3)](/dtk_create_shape/3.md)):

- \*

  *shp* can be used to modify a previously created shape. If it is non-null, the handle will be used to modify the shape referenced by *shp*: no new shape is created and the returned value is ensured to be *shp* in case of success, *NULL* otherwise. If *shp* is *NULL*, the function will attempt to create a new shape.

- \*

  *color* should point to a 4 float array containing a normalized RGBA value (i.e. each component is between 0.0 and 1.0).

## RETURN VALUE

In case of success the function returns the handle to the newly created or modified shape. If the *shp* argument is non-null, the handle returned is the same value. In case of error, *NULL* is returned.

## SEE ALSO

[**dtk\_load\_font**(3)](/dtk_load_font/3.md), [**dtk\_create\_shape**(3)](/dtk_create_shape/3.md)
