| 228 | } |
| 229 | |
| 230 | bool SdCardFontRegistry::discover() { |
| 231 | families_.clear(); |
| 232 | families_.reserve(MAX_SD_FAMILIES); |
| 233 | |
| 234 | // Hidden root is scanned first so it wins on name collisions, matching the |
| 235 | // sleep-folder pattern (/.sleep preferred over /sleep). |
| 236 | scanRoot(FONTS_DIR_HIDDEN, families_); |
| 237 | scanRoot(FONTS_DIR_VISIBLE, families_); |
| 238 | |
| 239 | // Sort families alphabetically |
| 240 | std::sort(families_.begin(), families_.end(), |
| 241 | [](const SdCardFontFamilyInfo& a, const SdCardFontFamilyInfo& b) { return a.name < b.name; }); |
| 242 | |
| 243 | // Cap at MAX_SD_FAMILIES |
| 244 | if (static_cast<int>(families_.size()) > MAX_SD_FAMILIES) { |
| 245 | families_.resize(MAX_SD_FAMILIES); |
| 246 | } |
| 247 | |
| 248 | LOG_DBG("SDREG", "Discovery complete: %d families", static_cast<int>(families_.size())); |
| 249 | return !families_.empty(); |
| 250 | } |
| 251 | |
| 252 | const char* SdCardFontRegistry::findFamilyRoot(const char* familyName) { |
| 253 | if (!familyName || !*familyName) return nullptr; |
no test coverage detected