Revert "feat: closest-pt size selection instead of ordinal slot" (#1949)
Reverts crosspoint-reader/crosspoint-reader#1912 This was meant to be more robust with partial SD card fonts, but causes trouble for folks using custom font sizes. We need a better approach to decouple numeric font sizes from S/M/L/XL settings.
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
#include <Logging.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
// --- SdCardFontFamilyInfo helpers ---
|
||||
@@ -40,21 +38,6 @@ std::vector<uint8_t> SdCardFontFamilyInfo::availableSizes() const {
|
||||
return sizes;
|
||||
}
|
||||
|
||||
const SdCardFontFileInfo* SdCardFontFamilyInfo::pickClosestSize(uint8_t targetPtSize) const {
|
||||
const SdCardFontFileInfo* selected = nullptr;
|
||||
int bestDiff = INT_MAX;
|
||||
for (const auto& f : files) {
|
||||
int diff = std::abs(static_cast<int>(f.pointSize) - static_cast<int>(targetPtSize));
|
||||
// Strict < ensures the first scan wins on ties; then tie-break by smaller
|
||||
// pointSize to make the choice independent of filesystem enumeration order.
|
||||
if (diff < bestDiff || (diff == bestDiff && selected && f.pointSize < selected->pointSize)) {
|
||||
bestDiff = diff;
|
||||
selected = &f;
|
||||
}
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
// --- SdCardFontRegistry ---
|
||||
|
||||
bool SdCardFontRegistry::parseFilename(const char* filename, uint8_t& size, uint8_t& style) {
|
||||
|
||||
Reference in New Issue
Block a user