Class Font

Class Documentation

class Font

Declaration: final

Resolved immutable CPU font data, shared by copies and independent of Context/toolkit lifetime.

Save reference(), then restore through FontService; the runtime handle and font bytes are not serialized.

Public Functions

Font() = default

Construct an empty handle.

Test it before querying reference(), faces() or collection().

bool operator==(const Font&) const noexcept = default

Declaration: [[nodiscard]]

Compare retained snapshot identity, including empty handles.

Equal reference strings alone do not imply equal snapshots.

inline explicit operator bool() const noexcept

Declaration: [[nodiscard]]

Return whether a snapshot is retained; default and moved-from handles are empty.

const std::string &reference() const

Declaration: [[nodiscard]]

Return the stable application reference for saving a selected choice.

The returned string borrows the retained snapshot. An empty handle throws failed_operation.

std::span<const FontFace> faces() const

Declaration: [[nodiscard]]

Borrow every retained primary/fallback style variant.

Keep a copy of this Font alive while using the span or its byte spans. An empty handle throws failed_operation; no file access occurs.

FontCollection collection(FontStyle style = {}) const

Declaration: [[nodiscard]]

Select one face per retained family, preferring matching italic state then nearest numeric weight; ties preserve retained order.

The returned collection shares immutable bytes independently of this handle. Empty handles throw failed_operation and allocation failures propagate. No discovery, file access or graphics work occurs.