/* Copyright (C) 2026 Carl Hetherington This file is part of libttf. libttf is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. libttf is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libttf. If not, see . */ #pragma once #include "table.h" #include #include namespace ttf { class NameTable; class InvalidScalerType : public std::runtime_error { public: InvalidScalerType(uint32_t scalar_type) : std::runtime_error(fmt::format("Invalid scaler type 0x{0:x}", scalar_type)) {} }; class Font { public: /** Read and parse a TTF font from a file */ Font(boost::filesystem::path const& ttf_file); /** Read and parse a TTF font from a block of memory */ Font(uint8_t const* data, int size); Font(Source& source); /** Write the font to a file */ void write(boost::filesystem::path const& ttf_file) const; std::shared_ptr name_table(); private: void read_source(Source& source); uint32_t _scalar_type = 0; uint16_t _num_tables = 0; /* Tables in the order that their data appears in the file * (not necessarily the same order as the headers) */ std::vector> _tables; }; }