---
name: "TTF_OpenFontWithProperties"
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_OpenFontWithProperties"
---

# TTF\_OpenFontWithProperties(3)

Create a font with the specified properties.

## NAME

TTF\_OpenFontWithProperties - Create a font with the specified properties.

## HEADER FILE

Defined in SDL3\_ttf/SDL\_ttf.h

## SYNOPSIS

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

**TTF\_Font \* TTF\_OpenFontWithProperties(SDL\_PropertiesID props);** **#define TTF\_PROP\_FONT\_CREATE\_FILENAME\_STRING**            *SDL\_ttf.font.create.filename"* **#define TTF\_PROP\_FONT\_CREATE\_IOSTREAM\_POINTER**           *SDL\_ttf.font.create.iostream"* **#define TTF\_PROP\_FONT\_CREATE\_IOSTREAM\_OFFSET\_NUMBER**     *SDL\_ttf.font.create.iostream.offset"* **#define TTF\_PROP\_FONT\_CREATE\_IOSTREAM\_AUTOCLOSE\_BOOLEAN** *SDL\_ttf.font.create.iostream.autoclose"* **#define TTF\_PROP\_FONT\_CREATE\_SIZE\_FLOAT**                 *SDL\_ttf.font.create.size"* **#define TTF\_PROP\_FONT\_CREATE\_FACE\_NUMBER**                *SDL\_ttf.font.create.face"* **#define TTF\_PROP\_FONT\_CREATE\_HORIZONTAL\_DPI\_NUMBER**      *SDL\_ttf.font.create.hdpi"* **#define TTF\_PROP\_FONT\_CREATE\_VERTICAL\_DPI\_NUMBER**        *SDL\_ttf.font.create.vdpi"* **#define TTF\_PROP\_FONT\_CREATE\_EXISTING\_FONT**              *SDL\_ttf.font.create.existing\_font"*

## DESCRIPTION

These are the supported properties:

•  **TTF\_PROP\_FONT\_CREATE\_FILENAME\_STRING** :\
   the font file to open, if an SDL\_IOStream isn't being used. This is\
   required if

**TTF\_PROP\_FONT\_CREATE\_IOSTREAM\_POINTER** and

**TTF\_PROP\_FONT\_CREATE\_EXISTING\_FONT** aren't set.

•  **TTF\_PROP\_FONT\_CREATE\_IOSTREAM\_POINTER** :\
   an SDL\_IOStream containing the font to be opened. This should not be\
   closed until the font is closed. This is required if

**TTF\_PROP\_FONT\_CREATE\_FILENAME\_STRING** and

**TTF\_PROP\_FONT\_CREATE\_EXISTING\_FONT** aren't set.

•  **TTF\_PROP\_FONT\_CREATE\_IOSTREAM\_OFFSET\_NUMBER** :\
   the offset in the iostream for the beginning of the font, defaults to 0.

•  **TTF\_PROP\_FONT\_CREATE\_IOSTREAM\_AUTOCLOSE\_BOOLEAN** :\
   true if closing the font should also close the associated SDL\_IOStream.

•  **TTF\_PROP\_FONT\_CREATE\_SIZE\_FLOAT** : the\
   point size of the font. 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.

•  **TTF\_PROP\_FONT\_CREATE\_FACE\_NUMBER** :\
   the face index of the font, if the font contains multiple font faces.

•  **TTF\_PROP\_FONT\_CREATE\_HORIZONTAL\_DPI\_NUMBER** :\
   the horizontal DPI to use for font rendering, defaults to

**TTF\_PROP\_FONT\_CREATE\_VERTICAL\_DPI\_NUMBER** if set, or 72 otherwise.

•  **TTF\_PROP\_FONT\_CREATE\_VERTICAL\_DPI\_NUMBER** :\
   the vertical DPI to use for font rendering, defaults to

**TTF\_PROP\_FONT\_CREATE\_HORIZONTAL\_DPI\_NUMBER** if set, or 72 otherwise.

•  **TTF\_PROP\_FONT\_CREATE\_EXISTING\_FONT** :\
   an optional  **TTF\_Font**\
  that, if set, will be used as the font\
   data source and the initial size and style of the new font.

## FUNCTION PARAMETERS

- *props*

  the properties to use.

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