Avara3D 0.2.0
C++ API reference
a3d::Font Class Reference

Owns font file data and basic format metadata. More...

#include <a3d/Font.h>

Public Types

enum class  Type : uint8_t { Unknown , OTF , TTF }
 Recognized font container types. More...
 

Public Member Functions

 Font (const std::filesystem::path &path)
 Loads font data from path and derives its name and type from the path. More...
 
 Font (std::unique_ptr< Buffer > buffer)
 Takes ownership of buffer as font data with no name or known type. More...
 
const std::optional< std::string > & name () const
 Returns the font name, or an empty optional when no name is known. More...
 
Type type () const
 Returns the detected or assigned font type. More...
 
const Bufferbuffer () const
 Returns the owned font-data Buffer, or nullptr when no Buffer is owned. More...
 

Detailed Description

Owns font file data and basic format metadata.

Copying a Font deep-copies its Buffer; moving transfers the owned data.

Definition at line 25 of file Font.h.

Member Enumeration Documentation

◆ Type

enum class a3d::Font::Type : uint8_t
strong

Recognized font container types.

Enumerator
Unknown 

Unknown or unspecified font type.

OTF 

OpenType font data.

TTF 

TrueType font data.

Definition at line 31 of file Font.h.

Constructor & Destructor Documentation

◆ Font() [1/2]

a3d::Font::Font ( const std::filesystem::path &  path)
explicit

Loads font data from path and derives its name and type from the path.

The name is the filename stem. The .otf and .ttf extensions select OTF and TTF respectively; other extensions leave the type Unknown.

Exceptions
std::runtime_errorif the file cannot be opened, sized, or read.

◆ Font() [2/2]

a3d::Font::Font ( std::unique_ptr< Buffer buffer)
explicit

Takes ownership of buffer as font data with no name or known type.

Member Function Documentation

◆ buffer()

const Buffer * a3d::Font::buffer ( ) const

Returns the owned font-data Buffer, or nullptr when no Buffer is owned.

◆ name()

const std::optional< std::string > & a3d::Font::name ( ) const

Returns the font name, or an empty optional when no name is known.

◆ type()

Type a3d::Font::type ( ) const

Returns the detected or assigned font type.


The documentation for this class was generated from the following file: