docs
Loading...
Searching...
No Matches
CAPI_FontFile.h

Overview

Font file interface.

#include <Ultralight/CAPI/CAPI_FontFile.h>

The font file interface represents a font file: either on-disk path or in-memory file contents.

See also
ULFontLoader

Functions

ULFontFile ulFontFileCreateFromFilePath (ULString file_path)
 Create a font file from an on-disk file path.
ULFontFile ulFontFileCreateFromBuffer (ULBuffer buffer)
 Create a font file from an in-memory buffer.
ULFontFile ulFontFileCreateFromFilePathWithFaceIndex (ULString file_path, int face_index)
 Create a font file from an on-disk file path, naming the face within a font collection.
ULFontFile ulFontFileCreateFromBufferWithFaceIndex (ULBuffer buffer, int face_index)
 Create a font file from an in-memory buffer, naming the face within a font collection.
void ulDestroyFontFile (ULFontFile font_file)
 Destroy a font file previously created with ulFontFileCreateFromFilePath() or ulFontFileCreateFromBuffer().
bool ulFontFileIsInMemory (ULFontFile font_file)
 Whether or not this font file was created from an in-memory buffer.
ULString ulFontFileGetFilePath (ULFontFile font_file)
 Get the file path for this font file (if created from a file path).
ULBuffer ulFontFileGetBuffer (ULFontFile font_file)
 Get the in-memory buffer for this font file (if created from a buffer).
int ulFontFileGetFaceIndex (ULFontFile font_file)
 Get the index of the face within a font collection, or -1 when the library chooses the face.
unsigned int ulFontFileGetHash (ULFontFile font_file)
 Get the unique hash for this font file.

Function Documentation

◆ ulDestroyFontFile()

void ulDestroyFontFile ( ULFontFile font_file)

Destroy a font file previously created with ulFontFileCreateFromFilePath() or ulFontFileCreateFromBuffer().

Parameters
font_fileThe font file to destroy.

◆ ulFontFileCreateFromBuffer()

ULFontFile ulFontFileCreateFromBuffer ( ULBuffer buffer)

Create a font file from an in-memory buffer.

Parameters
bufferA buffer containing the font file data (TTF/OTF).
Returns
A new font file instance. You must call ulDestroyFontFile() when finished.
Note
The font file keeps its own reference to the buffer, so you still call ulDestroyBuffer() on buffer when you're done with it (right after this call is fine).

◆ ulFontFileCreateFromBufferWithFaceIndex()

ULFontFile ulFontFileCreateFromBufferWithFaceIndex ( ULBuffer buffer,
int face_index )

Create a font file from an in-memory buffer, naming the face within a font collection.

Parameters
bufferA buffer containing the font file data (TTF/OTF, or a collection).
face_indexThe index of the face to use when the data is a font collection. Pass -1 to let the library choose the face that best matches the requested weight and style.
Returns
Returns a new font file instance. You must call ulDestroyFontFile() when finished.
Note
The font file keeps its own reference to the buffer, so you still call ulDestroyBuffer() on buffer when you're done with it (right after this call is fine).

◆ ulFontFileCreateFromFilePath()

ULFontFile ulFontFileCreateFromFilePath ( ULString file_path)

Create a font file from an on-disk file path.

Parameters
file_pathThe path to the font file on disk. The file should already exist.
Returns
A new font file instance. You must call ulDestroyFontFile() when finished.

◆ ulFontFileCreateFromFilePathWithFaceIndex()

ULFontFile ulFontFileCreateFromFilePathWithFaceIndex ( ULString file_path,
int face_index )

Create a font file from an on-disk file path, naming the face within a font collection.

Parameters
file_pathThe path to the font file on disk. The file should already exist.
face_indexThe index of the face to use when the file is a font collection (eg, a .ttc holding several families). Pass -1 to let the library choose the face that best matches the requested weight and style.
Returns
Returns a new font file instance. You must call ulDestroyFontFile() when finished.

◆ ulFontFileGetBuffer()

ULBuffer ulFontFileGetBuffer ( ULFontFile font_file)

Get the in-memory buffer for this font file (if created from a buffer).

Returns
The buffer, or NULL if created from a file path. Do not destroy the returned buffer. It stays valid until the next call to ulFontFileGetBuffer() on the same thread (for any font file).

◆ ulFontFileGetFaceIndex()

int ulFontFileGetFaceIndex ( ULFontFile font_file)

Get the index of the face within a font collection, or -1 when the library chooses the face.

◆ ulFontFileGetFilePath()

ULString ulFontFileGetFilePath ( ULFontFile font_file)

Get the file path for this font file (if created from a file path).

Returns
The file path, or an empty string if created from a buffer. Do not destroy the returned string. It stays valid until the next call to ulFontFileGetFilePath() on the same thread (for any font file); copy it via ulCreateStringFromCopy() to keep it.

◆ ulFontFileGetHash()

unsigned int ulFontFileGetHash ( ULFontFile font_file)

Get the unique hash for this font file.

◆ ulFontFileIsInMemory()

bool ulFontFileIsInMemory ( ULFontFile font_file)

Whether or not this font file was created from an in-memory buffer.

Go to the source code of this file.