diff options
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) { |