diff --git a/src/data/font.cpp b/src/data/font.cpp index 4a130134..65a9153f 100644 --- a/src/data/font.cpp +++ b/src/data/font.cpp @@ -37,7 +37,8 @@ bool Font::PreloadResourceFonts(String fontsDirectoryPath, bool recursive) { // tally fonts vector fontFilePaths; - if (!TallyResourceFonts(fontsDirectoryPath, fontFilePaths, recursive)) return false; + TallyResourceFonts(fontsDirectoryPath, fontFilePaths, recursive); + if (fontFilePaths.size() == 0) return false; // load fonts bool preloadHadErrors = false; @@ -53,25 +54,22 @@ bool Font::PreloadResourceFonts(String fontsDirectoryPath, bool recursive) { return false; } -bool Font::TallyResourceFonts(String fontsDirectoryPath, vector& fontFilePaths, bool recursive) { +void Font::TallyResourceFonts(String fontsDirectoryPath, vector& fontFilePaths, bool recursive) { wxDir fontsDirectory(fontsDirectoryPath); - String fontFileName = ""; - bool foundFonts = false; + String fontFileName = wxEmptyString; bool hasNext = fontsDirectory.GetFirst(&fontFileName); while (hasNext) { String fontFilePath = fontsDirectoryPath + fontFileName; if (wxDirExists(fontFilePath)) { if (recursive) { - foundFonts = foundFonts || TallyResourceFonts(fontFilePath + wxFileName::GetPathSeparator(), fontFilePaths, true); + TallyResourceFonts(fontFilePath + wxFileName::GetPathSeparator(), fontFilePaths, true); } } else if (fontFilePath.EndsWith(_(".ttf")) || fontFilePath.EndsWith(_(".otf"))) { - foundFonts = true; fontFilePaths.push_back(fontFilePath); } hasNext = fontsDirectory.GetNext(&fontFileName); } - return foundFonts; } bool Font::update(Context& ctx) { diff --git a/src/data/font.hpp b/src/data/font.hpp index 39a2a976..9a3368b1 100644 --- a/src/data/font.hpp +++ b/src/data/font.hpp @@ -51,8 +51,8 @@ public: /// Load fonts (.ttf or .otf) from the given directory and its subdirectories, returns true if there were errors static bool PreloadResourceFonts(String fontsDirectoryPath, bool recursive); - /// Adds font file paths from the given directory into fontFilePaths, returns true if fonts were found - static bool TallyResourceFonts(String fontsDirectoryPath, vector& fontFilePaths, bool recursive); + /// Adds font file paths from the given directory into fontFilePaths + static void TallyResourceFonts(String fontsDirectoryPath, vector& fontFilePaths, bool recursive); /// Update the scritables, returns true if there is a change bool update(Context& ctx); /// Add the given dependency to the dependent_scripts list for the variables this font depends on