#include "Font_Face_p.h" namespace renderive { Font_Face::Font_Face() : impl_(std::make_unique()) {} Font_Face::~Font_Face() = default; Font_Face::Font_Face(Font_Face&&) noexcept = default; Font_Face& Font_Face::operator=(Font_Face&&) noexcept = default; bool Font_Face::valid() const { return impl_->face.is_valid(); } std::string Font_Face::family_name() const { const BLString& name = impl_->face.family_name(); return std::string(name.data(), name.size()); } Font_Registry::Font_Registry() : impl_(std::make_unique()) {} Font_Registry::~Font_Registry() { set_default_face(nullptr); } std::shared_ptr Font_Registry::load_file(const std::filesystem::path& path) { auto face = std::make_shared(); auto file_path = path.string(); if (face->impl_->face.create_from_file(file_path.c_str()) != BL_SUCCESS) return nullptr; return face; } std::shared_ptr Font_Registry::load_memory(std::span data) { auto face = std::make_shared(); BLFontData font_data; if (font_data.create_from_data(reinterpret_cast(data.data()), data.size()) != BL_SUCCESS) return nullptr; if (face->impl_->face.create_from_data(font_data, 0) != BL_SUCCESS) return nullptr; return face; } void Font_Registry::set_default_face(std::shared_ptr face) { impl_->default_face = std::move(face); } std::shared_ptr Font_Registry::default_face() const { return impl_->default_face; } } // namespace renderive