---
name: "TTF_GetTextSubString"
section: "3"
platform: "linux"
package: "libsdl3-ttf-doc"
version: "3.2.2+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/TTF_GetTextSubString"
---

# TTF\_GetTextSubString(3)

Get the substring of a text object that surrounds a text offset.

## NAME

TTF\_GetTextSubString - Get the substring of a text object that surrounds a text offset.

## HEADER FILE

Defined in SDL3\_ttf/SDL\_ttf.h

## SYNOPSIS

```
#include "SDL3_ttf/SDL_ttf.h"
```

**bool TTF\_GetTextSubString(TTF\_Text \*text, int offset, TTF\_SubString \*substring);**

## DESCRIPTION

If **offset** is less than 0, this will return a zero length substring at the beginning of the text with the

**TTF\_SUBSTRING\_TEXT\_START**\
  flag set. If **offset** is greater than or equal to the length of the text string, this will return a zero length substring at the end of the text with the

**TTF\_SUBSTRING\_TEXT\_END**\
  flag set.

## FUNCTION PARAMETERS

- *text*

  the  **TTF\_Text**\
    to query.

- *offset*

  a byte offset into the text string.

- *substring*

  a pointer filled in with the substring containing the offset.

## RETURN VALUE

Returns true on success or false on failure; call SDL\_GetError() for more information.

## THREAD SAFETY

This function should be called on the thread that created the text.

## AVAILABILITY

This function is available since SDL\_ttf 3.0.0.
