Add global instance of font factory
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
namespace OpenVulkano::Scene
|
namespace OpenVulkano::Scene
|
||||||
{
|
{
|
||||||
|
FontAtlasFactory FontAtlasFactory::INSTANCE = FontAtlasFactory(); // Global factory
|
||||||
|
|
||||||
FontAtlasFactory::FontIdentifier::FontIdentifier(const std::string& font_, const std::set<uint32_t>& charset,
|
FontAtlasFactory::FontIdentifier::FontIdentifier(const std::string& font_, const std::set<uint32_t>& charset,
|
||||||
SubpixelLayout subpixelLayout_, float ptSize_,
|
SubpixelLayout subpixelLayout_, float ptSize_,
|
||||||
FontAtlasType atlasType_)
|
FontAtlasType atlasType_)
|
||||||
|
|||||||
@@ -26,19 +26,25 @@ namespace OpenVulkano::Scene
|
|||||||
float ptSize = 0;
|
float ptSize = 0;
|
||||||
FontAtlasType atlasType;
|
FontAtlasType atlasType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static FontAtlasFactory INSTANCE;
|
||||||
|
|
||||||
|
const bool m_allowSystemFonts;
|
||||||
|
mutable std::map<FontIdentifier, FontAtlas::Ptr> m_atlasesCache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FontAtlasFactory(bool allowSystemFonts = true) : m_allowSystemFonts(allowSystemFonts) {}
|
static FontAtlasFactory& GetInstance() { return INSTANCE; }
|
||||||
|
|
||||||
|
FontAtlasFactory(const bool allowSystemFonts = true) : m_allowSystemFonts(allowSystemFonts) {}
|
||||||
|
|
||||||
[[nodiscard]] FontAtlas::Ptr GetFontAtlasScalable(const std::string& fontIdentifier, bool msdf = true,
|
[[nodiscard]] FontAtlas::Ptr GetFontAtlasScalable(const std::string& fontIdentifier, bool msdf = true,
|
||||||
const std::set<uint32_t>& charset = {}) const;
|
const std::set<uint32_t>& charset = {}) const;
|
||||||
|
|
||||||
[[nodiscard]] FontAtlas::Ptr GetFontAtlas(const std::string& fontIdentifier, float ptSize,
|
[[nodiscard]] FontAtlas::Ptr GetFontAtlas(const std::string& fontIdentifier, float ptSize,
|
||||||
SubpixelLayout subpixelLayout = SubpixelLayout::UNKNOWN,
|
SubpixelLayout subpixelLayout = SubpixelLayout::UNKNOWN,
|
||||||
const std::set<uint32_t>& charset = {}) const;
|
const std::set<uint32_t>& charset = {}) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Array<char> FindFont(const std::string& fontFile) const;
|
Array<char> FindFont(const std::string& fontFile) const;
|
||||||
|
|
||||||
private:
|
|
||||||
const bool m_allowSystemFonts;
|
|
||||||
mutable std::map<FontIdentifier, FontAtlas::Ptr> m_atlasesCache;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user