BLFontData Class Referencefinal

Font data [C++ API].

Member Functions

Construction & Destruction
Overloaded Operators
Common Functionality
Create Functionality

Additional Inherited Members

- Public Attributes inherited from BLObjectCore

Member Function Documentation

bool BLFontData::isValid() const◆ 

Tests whether the font data is a built-in null instance.

bool BLFontData::empty() const◆ 

Tests whether the font data is empty, which is the same as !isValid().

BLResult BLFontData::createFromFile(const char* fileName, BLFileReadFlags readFlags = BL_FILE_READ_NO_FLAGS)◆ 

Creates a BLFontData from a file specified by the given fileName.

The readFlags argument allows to specify flags that will be passed to BLFileSystem::readFile() to read the content of the file. It's possible to use memory mapping to get its content, which is the recommended way for reading system fonts. The best combination is to use BL_FILE_READ_MMAP_ENABLED flag combined with BL_FILE_READ_MMAP_AVOID_SMALL. This combination means to try to use memory mapping only when the size of the font is greater than a minimum value (determined by Blend2D), and would fallback to a regular open/read in case the memory mapping is not possible or failed for some other reason. Please note that not all files can be memory mapped so BL_FILE_READ_MMAP_NO_FALLBACK flag is not recommended.

BLResult BLFontData::createFromData(const BLArray<uint8_t>& data)[1/2]◆ 

Creates a BLFontData from the given data stored in BLArray<uint8_t>

The given data would be weak copied on success so the given array can be safely destroyed after the function returns.

The weak copy of the passed data is internal and there is no API to access it after the function returns. The reason for making it internal is that multiple implementations of BLFontData may exist and some can only store data at table level, so Blend2D doesn't expose the detail about how the data is stored.

BLResult BLFontData::createFromData(const void* data, size_t dataSize, BLDestroyExternalDataFunc destroyFunc = nullptr, void* userData = nullptr)[2/2]◆ 

Creates BLFontData from the given data of the given size.

Optionally a destroyFunc can be used as a notifier that will be called when the data is no longer needed. Destroy func will be called with userData.

BLFontFaceType BLFontData::faceType() const◆ 

Type of font face that this data describes.

It doesn't matter if the content is a single font or a collection. In any case the faceType() would always return the type of the font face that will be created by BLFontFace::createFromData().

uint32_t BLFontData::faceCount() const◆ 

Returns the number of faces of this font data.

If the data is not initialized the result would be always zero. If the data is initialized to a single font it would be 1, and if the data is initialized to a font collection then the return would correspond to the number of font faces within that collection.

You should not use faceCount() to check whether the font is a collection as it's possible to have a font-collection with just a single font. Using isCollection() is more reliable and would always return the right value.

BLFontDataFlags BLFontData::flags() const◆ 

Returns font data flags.

bool BLFontData::isCollection() const◆ 

Tests whether this font data is a font-collection.

BLResult BLFontData::getTableTags(uint32_t faceIndex, BLArray<BLTag>& dst) const◆ 

Populates dst array with all table tags provided by font face at the given faceIndex.