---
name: "TTF_OpenFont"
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_OpenFont"
---

# TTF\_OpenFont(3)

Create a font from a file, using a specified point size.

## NAME

TTF\_OpenFont - Create a font from a file, using a specified point size.

## HEADER FILE

Defined in SDL3\_ttf/SDL\_ttf.h

## SYNOPSIS

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

**TTF\_Font \* TTF\_OpenFont(const char \*file, 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.

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

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

## FUNCTION PARAMETERS

- *file*

  path to font file.

- *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)
