/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #include "FontAtlas.hpp" #include "SubpixelLayout.hpp" #include "Data/Containers/Array.hpp" namespace OpenVulkano::Scene { class FontAtlasFactory final { struct FontIdentifier { FontIdentifier(const std::string& font_, const std::set& charset, SubpixelLayout subpixelLayout_, float ptSize_, FontAtlasType atlasType_); bool operator<(const FontIdentifier& other) const; std::string font; uint32_t charsetHash = 0; SubpixelLayout subpixelLayout = SubpixelLayout::UNKNOWN; float ptSize = 0; FontAtlasType atlasType; }; static FontAtlasFactory INSTANCE; const bool m_allowSystemFonts; mutable std::map m_atlasesCache; public: static FontAtlasFactory& GetInstance() { return INSTANCE; } FontAtlasFactory(const bool allowSystemFonts = true) : m_allowSystemFonts(allowSystemFonts) {} [[nodiscard]] FontAtlas::Ptr GetFontAtlasScalable(const std::string& fontIdentifier, bool msdf = true, const std::set& charset = {}) const; [[nodiscard]] FontAtlas::Ptr GetFontAtlas(const std::string& fontIdentifier, float ptSize, SubpixelLayout subpixelLayout = SubpixelLayout::UNKNOWN, const std::set& charset = {}) const; private: [[deprecated]] Array FindFont(const std::string& fontFile) const; }; }