Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
font.hpp
Go to the documentation of this file.
1/*
2 Copyright 2021 natinusala
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#pragma once
18
19#include <string>
20#include <unordered_map>
22
23namespace aurore
24{
25
26static constexpr const int FONT_INVALID = -1;
27
28static const std::string FONT_REGULAR = "regular"; // regular Latin font
29static const std::string FONT_KOREAN_REGULAR = "korean"; // regular Korean font
30static const std::string FONT_CHINESE_SIMPLIFIED = "zh-Hans"; // Simplified Chinese
31static const std::string FONT_CHINESE_SIMPLIFIED_EXT = "zh-Hans-ext"; // Simplified Chinese Extended
32static const std::string FONT_CHINESE_TRADITIONAL = "zh-Hant"; // Traditional Chinese
33static const std::string FONT_JAPANESE = "ja"; // Japanese (where the regular font has no kana nor kanji)
34static const std::string FONT_MATERIAL_ICONS = "material"; // Material icons font
35static const std::string FONT_SWITCH_ICONS = "switch"; // the controller buttons, at the code points of the Switch's shared font (U+E0E0 for A...)
36static const std::string FONT_EMOJI = "emoji";
37
38typedef std::unordered_map<std::string, int> FontStash;
39
40// Platform interface to load fonts from disk or other sources (system / shared font...)
42{
43 public:
44 inline static std::string USER_FONT_PATH = AURORE_ASSET("font/font.ttf");
45 inline static std::string USER_ICON_PATH = AURORE_ASSET("font/icon.ttf");
46 inline static std::string USER_EMOJI_PATH;
47
48 virtual ~FontLoader() { }
56 virtual void loadFonts() = 0;
57
58 protected:
63 bool loadFontFromFile(std::string fontName, std::string filePath);
64
70};
71
72} // namespace aurore
#define AURORE_ASSET(_str)
Definition assets.hpp:26
Definition font.hpp:42
static std::string USER_ICON_PATH
Definition font.hpp:45
static std::string USER_FONT_PATH
Definition font.hpp:44
bool loadMaterialFromResources()
bool loadFontFromFile(std::string fontName, std::string filePath)
virtual ~FontLoader()
Definition font.hpp:48
static std::string USER_EMOJI_PATH
Definition font.hpp:46
virtual void loadFonts()=0
Definition actions.hpp:25
static constexpr const int FONT_INVALID
Definition font.hpp:26
static const std::string FONT_CHINESE_SIMPLIFIED_EXT
Definition font.hpp:31
static const std::string FONT_MATERIAL_ICONS
Definition font.hpp:34
std::unordered_map< std::string, int > FontStash
Definition font.hpp:38
static const std::string FONT_CHINESE_TRADITIONAL
Definition font.hpp:32
static const std::string FONT_EMOJI
Definition font.hpp:36
static const std::string FONT_SWITCH_ICONS
Definition font.hpp:35
static const std::string FONT_CHINESE_SIMPLIFIED
Definition font.hpp:30
static const std::string FONT_KOREAN_REGULAR
Definition font.hpp:29
static const std::string FONT_JAPANESE
Definition font.hpp:33
static const std::string FONT_REGULAR
Definition font.hpp:28