diff options
Diffstat (limited to 'source/30-game/FontManager.cpp')
-rw-r--r-- | source/30-game/FontManager.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/source/30-game/FontManager.cpp b/source/30-game/FontManager.cpp new file mode 100644 index 0000000..11a3a5b --- /dev/null +++ b/source/30-game/FontManager.cpp @@ -0,0 +1,94 @@ +#include "FontManager.hpp" + +RcPtr<Font> FontManager::sans{ new Font() }; +RcPtr<Font> FontManager::serif{ new Font() }; +RcPtr<Font> FontManager::monospace{ new Font() }; + +const RcPtr<Font>& FontManager::GetDefaultFont() { + return sans; +} + +const Font* FontManager::ResolveFallback(const Font* font) { + if (font == nullptr) { + return FontManager::sans.Get(); + } else { + return font; + } +} + +const RcPtr<Font>& FontManager::ResolveFallback(const RcPtr<Font>& font) { + if (font == nullptr) { + return FontManager::sans; + } else { + return font; + } +} + +void FontManager::Init() { + Font::LoadingCandidate sansFiles[] = { + { + .ttfPath = "fonts/NotoSans-Regular.ttf", + .glyphRange = Font::GetGlyphRangesDefault(), + .type = FontType::Regular, + }, + { + .ttfPath = "fonts/NotoSans-Italic.ttf", + .glyphRange = Font::GetGlyphRangesDefault(), + .type = FontType::Italic, + }, + { + .ttfPath = "fonts/NotoSans-Bold.ttf", + .glyphRange = Font::GetGlyphRangesDefault(), + .type = FontType::Bold, + }, + { + .ttfPath = "fonts/NotoSans-BoldItalic.ttf", + .glyphRange = Font::GetGlyphRangesDefault(), + .type = FontType::BoldItalic, + }, + { + .ttfPath = "fonts/NotoSansSC-Regular.otf", + .glyphRange = Font::GetGlyphRangesChineseSimplifiedCommon(), + .type = FontType::Regular, + }, + }; + + sans->Init(sansFiles, 18.0f); + + Font::LoadingCandidate serifFiles[] = { + { + .ttfPath = "fonts/NotoSerif-Regular.ttf", + .glyphRange = Font::GetGlyphRangesDefault(), + .type = FontType::Regular, + }, + { + .ttfPath = "fonts/NotoSerif-Italic.ttf", + .glyphRange = Font::GetGlyphRangesDefault(), + .type = FontType::Italic, + }, + { + .ttfPath = "fonts/NotoSerif-Bold.ttf", + .glyphRange = Font::GetGlyphRangesDefault(), + .type = FontType::Bold, + }, + { + .ttfPath = "fonts/NotoSerif-BoldItalic.ttf", + .glyphRange = Font::GetGlyphRangesDefault(), + .type = FontType::BoldItalic, + }, + }; + + serif->Init(sansFiles, 18.0f); + + Font::LoadingCandidate monospacedFiles[] = { + { + .ttfPath = "fonts/NotoMono-Regular.ttf", + .glyphRange = Font::GetGlyphRangesDefault(), + .type = FontType::Regular, + }, + }; + monospace->Init(monospacedFiles, 18.0f); +} + +void FontManager::Shutdown() { +} |