Clean project structure.

This commit is contained in:
jmsgrogan 2023-01-17 10:13:25 +00:00
parent 78a4fa99ff
commit 947bf937fd
496 changed files with 206 additions and 137 deletions

View file

@ -0,0 +1,57 @@
#include "FontsManager.h"
#ifdef HAS_FREETYPE
#include "FreeTypeFontEngine.h"
#else
#include "BasicFontEngine.h"
#endif
#include "FontGlyph.h"
FontsManager::FontsManager()
{
#ifdef HAS_FREETYPE
mFontEngine = std::make_unique<FreeTypeFontEngine>();
mUsesGlyphs = true;
#else
mFontEngine = std::make_unique<BasicFontEngine>();
#endif
mFontEngine->initialize();
}
std::unique_ptr<FontsManager> FontsManager::Create()
{
return std::make_unique<FontsManager>();
}
bool FontsManager::usesGlyphs() const
{
return mUsesGlyphs;
}
IFontEngine* FontsManager::getFontEngine() const
{
return mFontEngine.get();
}
FontGlyph* FontsManager::getGlyph(const std::string& fontFace, float size, uint32_t c)
{
auto path = std::filesystem::path("truetype/liberation/LiberationSans-Regular.ttf");
mFontEngine->loadFontFace(path, size);
auto iter = mGlyphs.find(c);
if(iter != mGlyphs.end())
{
return iter->second.get();
}
else
{
auto glyph = mFontEngine->loadGlyph(c);
auto glyph_ptr = glyph.get();
mGlyphs[c] = std::move(glyph);
return glyph_ptr;
}
}