diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-11-06 13:54:02 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-11-07 14:24:32 +0100 |
commit | 8025d1075db0779bde635148f6e38303eb29d6c8 (patch) | |
tree | 64dce4cc00fa55edba0ab7d2522e13473e6ef3c4 /src/ResourceLoader.cpp | |
parent | f8b3a9d055bfc0e4bb9e9a570ccc8853ec38a225 (diff) |
Formatted text with color in matrix, monospace for codeblocks
Diffstat (limited to 'src/ResourceLoader.cpp')
-rw-r--r-- | src/ResourceLoader.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/ResourceLoader.cpp b/src/ResourceLoader.cpp index e086ee7..86687d2 100644 --- a/src/ResourceLoader.cpp +++ b/src/ResourceLoader.cpp @@ -12,9 +12,9 @@ #include <assert.h> static std::string resource_root; -static std::array<std::unique_ptr<mgl::MemoryMappedFile>, 4> font_file_cache; +static std::array<std::unique_ptr<mgl::MemoryMappedFile>, 5> font_file_cache; // font_cache[(unsigned int)font_type][character_size] -static std::array<std::unordered_map<unsigned int, std::unique_ptr<mgl::Font>>, 4> font_cache; +static std::array<std::unordered_map<unsigned int, std::unique_ptr<mgl::Font>>, 5> font_cache; static std::unordered_map<std::string, std::unique_ptr<mgl::Texture>> texture_cache; namespace QuickMedia { @@ -100,6 +100,23 @@ namespace QuickMedia::FontLoader { } break; } + case FontType::LATIN_MONOSPACE: { + const char *args[] = { "fc-match", "monospace:lang=en", "file", nullptr }; + if(get_config().use_system_fonts && exec_program(args, accumulate_string, &output) == 0 && output.size() > 6) { + Path path = strip(output.substr(6)); + noto_directories.push_back(path.parent().data); + font_file_name = path.filename(); + } else if(!get_config().font.latin_monospace.empty() && find_font(get_config().font.latin_monospace, found_font_filepath)) { + const Path font_path = found_font_filepath; + noto_directories.push_back(font_path.parent().data); + font_file_name = font_path.filename(); + } else { + noto_directories.push_back("/usr/share/fonts/noto"); + noto_directories.push_back("/usr/share/fonts/truetype/noto"); + font_file_name = "NotoSansMono-Regular.ttf"; + } + break; + } case FontType::CJK: { const char *args[] = { "fc-match", "sans:lang=ja", "file", nullptr }; if(get_config().use_system_fonts && exec_program(args, accumulate_string, &output) == 0 && output.size() > 6) { |