From 8025d1075db0779bde635148f6e38303eb29d6c8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 6 Nov 2022 13:54:02 +0100 Subject: Formatted text with color in matrix, monospace for codeblocks --- src/ResourceLoader.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/ResourceLoader.cpp') 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 static std::string resource_root; -static std::array, 4> font_file_cache; +static std::array, 5> font_file_cache; // font_cache[(unsigned int)font_type][character_size] -static std::array>, 4> font_cache; +static std::array>, 5> font_cache; static std::unordered_map> 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) { -- cgit v1.2.3