---
name: "TTF_OpenFontIO"
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_OpenFontIO"
---

# TTF\_OpenFontIO(3)

Create a font from an SDL\_IOStream, using a specified point size.

## NAME

TTF\_OpenFontIO - Create a font from an SDL\_IOStream, using a specified point size.

## HEADER FILE

Defined in SDL3\_ttf/SDL\_ttf.h

## SYNOPSIS

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

**TTF\_Font \* TTF\_OpenFontIO(SDL\_IOStream \*src, bool closeio, float ptsize);**

## DESCRIPTION

Some .fon fonts will have several sizes embedded in the file, so the point size becomes the index of choosing which size. If the value is too high, the last indexed size will be the default.

If **closeio** is true, **src** will be automatically closed once the font is closed. Otherwise you should keep **src** open until the font is closed.

When done with the returned  **TTF\_Font** , use

**TTF\_CloseFont** () to dispose of it.

## FUNCTION PARAMETERS

- *src*

  an SDL\_IOStream to provide a font file's data.

- *closeio*

  true to close **src** when the font is closed, false to leave it open.

- *ptsize*

  point size to use for the newly-opened font.

## RETURN VALUE

( **TTF\_Font**\
  \*) Returns a valid  **TTF\_Font** , or NULL on failure; call SDL\_GetError() for more information.

## THREAD SAFETY

It is safe to call this function from any thread.

## AVAILABILITY

This function is available since SDL\_ttf 3.0.0.

## SEE ALSO

**•**(3), [**TTF\_CloseFont**(3)](/TTF_CloseFont/3.md)
