chore: Move opendyslexic from flash to SD (#2231)
This commit is contained in:
+11
-23
@@ -194,7 +194,17 @@ bool CrossPointSettings::loadFromBinaryFile() {
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
readAndValidate(inputFile, sideButtonLayout, SIDE_BUTTON_LAYOUT_COUNT);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
readAndValidate(inputFile, fontFamily, FONT_FAMILY_COUNT);
|
||||
{
|
||||
uint8_t legacyFontFamily;
|
||||
serialization::readPod(inputFile, legacyFontFamily);
|
||||
if (legacyFontFamily < BUILTIN_FONT_COUNT) {
|
||||
fontFamily = legacyFontFamily;
|
||||
} else if (legacyFontFamily == LEGACY_OPENDYSLEXIC) {
|
||||
fontFamily = NOTOSERIF;
|
||||
strncpy(sdFontFamilyName, "OpenDyslexic", sizeof(sdFontFamilyName) - 1);
|
||||
sdFontFamilyName[sizeof(sdFontFamilyName) - 1] = '\0';
|
||||
}
|
||||
}
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
readAndValidate(inputFile, fontSize, FONT_SIZE_COUNT);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
@@ -308,16 +318,6 @@ float CrossPointSettings::getReaderLineCompression() const {
|
||||
case WIDE:
|
||||
return 1.0f;
|
||||
}
|
||||
case OPENDYSLEXIC:
|
||||
switch (lineSpacing) {
|
||||
case TIGHT:
|
||||
return 0.90f;
|
||||
case NORMAL:
|
||||
default:
|
||||
return 0.95f;
|
||||
case WIDE:
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,17 +378,5 @@ int CrossPointSettings::getReaderFontId() const {
|
||||
case EXTRA_LARGE:
|
||||
return NOTOSANS_18_FONT_ID;
|
||||
}
|
||||
case OPENDYSLEXIC:
|
||||
switch (fontSize) {
|
||||
case SMALL:
|
||||
return OPENDYSLEXIC_8_FONT_ID;
|
||||
case MEDIUM:
|
||||
default:
|
||||
return OPENDYSLEXIC_10_FONT_ID;
|
||||
case LARGE:
|
||||
return OPENDYSLEXIC_12_FONT_ID;
|
||||
case EXTRA_LARGE:
|
||||
return OPENDYSLEXIC_14_FONT_ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,8 @@ class CrossPointSettings {
|
||||
enum SIDE_BUTTON_LAYOUT { PREV_NEXT = 0, NEXT_PREV = 1, SIDE_BUTTONS_DISABLED = 2, SIDE_BUTTON_LAYOUT_COUNT };
|
||||
|
||||
// Font family options (built-in fonts only; SD card fonts use sdFontFamilyName)
|
||||
enum FONT_FAMILY { NOTOSERIF = 0, NOTOSANS = 1, OPENDYSLEXIC = 2, FONT_FAMILY_COUNT };
|
||||
enum FONT_FAMILY { NOTOSERIF = 0, NOTOSANS = 1, FONT_FAMILY_COUNT };
|
||||
static constexpr uint8_t LEGACY_OPENDYSLEXIC = 2;
|
||||
static constexpr uint8_t BUILTIN_FONT_COUNT = FONT_FAMILY_COUNT;
|
||||
// Font size options
|
||||
enum FONT_SIZE { SMALL = 0, MEDIUM = 1, LARGE = 2, EXTRA_LARGE = 3, FONT_SIZE_COUNT };
|
||||
|
||||
+10
-1
@@ -244,11 +244,20 @@ bool JsonSettingsIO::loadSettings(CrossPointSettings& s, const char* json, bool*
|
||||
CrossPointSettings::validateFrontButtonMapping(s);
|
||||
|
||||
// Font family — uses dynamic getter/setter in SettingsList so the generic loop skips it.
|
||||
s.fontFamily = clamp(doc["fontFamily"] | (uint8_t)0, CrossPointSettings::BUILTIN_FONT_COUNT, 0);
|
||||
const uint8_t storedFontFamily = doc["fontFamily"] | (uint8_t)0;
|
||||
s.fontFamily = clamp(storedFontFamily, CrossPointSettings::BUILTIN_FONT_COUNT, 0);
|
||||
// SD card font family name — not in SettingsList, load manually
|
||||
const char* sfn = doc["sdFontFamilyName"] | "";
|
||||
strncpy(s.sdFontFamilyName, sfn, sizeof(s.sdFontFamilyName) - 1);
|
||||
s.sdFontFamilyName[sizeof(s.sdFontFamilyName) - 1] = '\0';
|
||||
if (storedFontFamily == CrossPointSettings::LEGACY_OPENDYSLEXIC && s.sdFontFamilyName[0] == '\0') {
|
||||
s.fontFamily = CrossPointSettings::NOTOSERIF;
|
||||
strncpy(s.sdFontFamilyName, "OpenDyslexic", sizeof(s.sdFontFamilyName) - 1);
|
||||
s.sdFontFamilyName[sizeof(s.sdFontFamilyName) - 1] = '\0';
|
||||
if (needsResave) *needsResave = true;
|
||||
} else if (storedFontFamily >= CrossPointSettings::BUILTIN_FONT_COUNT) {
|
||||
if (needsResave) *needsResave = true;
|
||||
}
|
||||
|
||||
// Language -- stored as code string for stability across enum reorders.
|
||||
if (doc["language"].is<const char*>()) {
|
||||
|
||||
+2
-4
@@ -18,7 +18,7 @@
|
||||
// are appended after the built-in fonts. Otherwise only built-in fonts are listed.
|
||||
inline SettingInfo buildFontFamilySetting(const SdCardFontRegistry* registry) {
|
||||
// Built-in font labels (StrId)
|
||||
std::vector<StrId> enumValues = {StrId::STR_NOTO_SERIF, StrId::STR_NOTO_SANS, StrId::STR_OPEN_DYSLEXIC};
|
||||
std::vector<StrId> enumValues = {StrId::STR_NOTO_SERIF, StrId::STR_NOTO_SANS};
|
||||
// Runtime string labels for SD card fonts
|
||||
std::vector<std::string> enumStringValues;
|
||||
|
||||
@@ -41,7 +41,6 @@ inline SettingInfo buildFontFamilySetting(const SdCardFontRegistry* registry) {
|
||||
if (sdFontCount > 0) {
|
||||
allStringValues.push_back(I18N.get(StrId::STR_NOTO_SERIF));
|
||||
allStringValues.push_back(I18N.get(StrId::STR_NOTO_SANS));
|
||||
allStringValues.push_back(I18N.get(StrId::STR_OPEN_DYSLEXIC));
|
||||
allStringValues.insert(allStringValues.end(), enumStringValues.begin(), enumStringValues.end());
|
||||
}
|
||||
|
||||
@@ -134,8 +133,7 @@ inline std::vector<SettingInfo> getSettingsList(const SdCardFontRegistry* regist
|
||||
// Built-in font-family entry. Replaced per-call with a registry-aware
|
||||
// version when SD fonts are installed.
|
||||
SettingInfo::Enum(StrId::STR_FONT_FAMILY, &CrossPointSettings::fontFamily,
|
||||
{StrId::STR_NOTO_SERIF, StrId::STR_NOTO_SANS, StrId::STR_OPEN_DYSLEXIC}, "fontFamily",
|
||||
StrId::STR_CAT_READER),
|
||||
{StrId::STR_NOTO_SERIF, StrId::STR_NOTO_SANS}, "fontFamily", StrId::STR_CAT_READER),
|
||||
SettingInfo::Enum(StrId::STR_FONT_SIZE, &CrossPointSettings::fontSize,
|
||||
{StrId::STR_SMALL, StrId::STR_MEDIUM, StrId::STR_LARGE, StrId::STR_X_LARGE}, "fontSize",
|
||||
StrId::STR_CAT_READER),
|
||||
|
||||
@@ -21,7 +21,6 @@ void FontSelectionActivity::onEnter() {
|
||||
|
||||
fonts_.push_back({I18N.get(StrId::STR_NOTO_SERIF), true, 0});
|
||||
fonts_.push_back({I18N.get(StrId::STR_NOTO_SANS), true, 1});
|
||||
fonts_.push_back({I18N.get(StrId::STR_OPEN_DYSLEXIC), true, 2});
|
||||
|
||||
if (registry_) {
|
||||
const auto& families = registry_->getFamilies();
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
#define NOTOSANS_14_FONT_ID (-1589315735)
|
||||
#define NOTOSANS_16_FONT_ID (1669013660)
|
||||
#define NOTOSANS_18_FONT_ID (37077304)
|
||||
#define OPENDYSLEXIC_8_FONT_ID (-853313197)
|
||||
#define OPENDYSLEXIC_10_FONT_ID (963754926)
|
||||
#define OPENDYSLEXIC_12_FONT_ID (858950283)
|
||||
#define OPENDYSLEXIC_14_FONT_ID (1877344218)
|
||||
#define UI_10_FONT_ID (22918846)
|
||||
#define UI_12_FONT_ID (1635686837)
|
||||
#define SMALL_FONT_ID (674098198)
|
||||
@@ -27,10 +23,6 @@ static_assert(NOTOSANS_12_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
static_assert(NOTOSANS_14_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
static_assert(NOTOSANS_16_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
static_assert(NOTOSANS_18_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
static_assert(OPENDYSLEXIC_8_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
static_assert(OPENDYSLEXIC_10_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
static_assert(OPENDYSLEXIC_12_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
static_assert(OPENDYSLEXIC_14_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
static_assert(UI_10_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
static_assert(UI_12_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
static_assert(SMALL_FONT_ID != 0, "Font ID collision with sentinel");
|
||||
|
||||
@@ -94,30 +94,6 @@ EpdFont notosans18BoldItalicFont(¬osans_18_bolditalic);
|
||||
EpdFontFamily notosans18FontFamily(¬osans18RegularFont, ¬osans18BoldFont, ¬osans18ItalicFont,
|
||||
¬osans18BoldItalicFont);
|
||||
|
||||
EpdFont opendyslexic8RegularFont(&opendyslexic_8_regular);
|
||||
EpdFont opendyslexic8BoldFont(&opendyslexic_8_bold);
|
||||
EpdFont opendyslexic8ItalicFont(&opendyslexic_8_italic);
|
||||
EpdFont opendyslexic8BoldItalicFont(&opendyslexic_8_bolditalic);
|
||||
EpdFontFamily opendyslexic8FontFamily(&opendyslexic8RegularFont, &opendyslexic8BoldFont, &opendyslexic8ItalicFont,
|
||||
&opendyslexic8BoldItalicFont);
|
||||
EpdFont opendyslexic10RegularFont(&opendyslexic_10_regular);
|
||||
EpdFont opendyslexic10BoldFont(&opendyslexic_10_bold);
|
||||
EpdFont opendyslexic10ItalicFont(&opendyslexic_10_italic);
|
||||
EpdFont opendyslexic10BoldItalicFont(&opendyslexic_10_bolditalic);
|
||||
EpdFontFamily opendyslexic10FontFamily(&opendyslexic10RegularFont, &opendyslexic10BoldFont, &opendyslexic10ItalicFont,
|
||||
&opendyslexic10BoldItalicFont);
|
||||
EpdFont opendyslexic12RegularFont(&opendyslexic_12_regular);
|
||||
EpdFont opendyslexic12BoldFont(&opendyslexic_12_bold);
|
||||
EpdFont opendyslexic12ItalicFont(&opendyslexic_12_italic);
|
||||
EpdFont opendyslexic12BoldItalicFont(&opendyslexic_12_bolditalic);
|
||||
EpdFontFamily opendyslexic12FontFamily(&opendyslexic12RegularFont, &opendyslexic12BoldFont, &opendyslexic12ItalicFont,
|
||||
&opendyslexic12BoldItalicFont);
|
||||
EpdFont opendyslexic14RegularFont(&opendyslexic_14_regular);
|
||||
EpdFont opendyslexic14BoldFont(&opendyslexic_14_bold);
|
||||
EpdFont opendyslexic14ItalicFont(&opendyslexic_14_italic);
|
||||
EpdFont opendyslexic14BoldItalicFont(&opendyslexic_14_bolditalic);
|
||||
EpdFontFamily opendyslexic14FontFamily(&opendyslexic14RegularFont, &opendyslexic14BoldFont, &opendyslexic14ItalicFont,
|
||||
&opendyslexic14BoldItalicFont);
|
||||
#endif // OMIT_FONTS
|
||||
|
||||
EpdFont smallFont(¬osans_8_regular);
|
||||
@@ -315,10 +291,6 @@ void setupDisplayAndFonts(bool seamless = false) {
|
||||
renderer.insertFont(NOTOSANS_14_FONT_ID, notosans14FontFamily);
|
||||
renderer.insertFont(NOTOSANS_16_FONT_ID, notosans16FontFamily);
|
||||
renderer.insertFont(NOTOSANS_18_FONT_ID, notosans18FontFamily);
|
||||
renderer.insertFont(OPENDYSLEXIC_8_FONT_ID, opendyslexic8FontFamily);
|
||||
renderer.insertFont(OPENDYSLEXIC_10_FONT_ID, opendyslexic10FontFamily);
|
||||
renderer.insertFont(OPENDYSLEXIC_12_FONT_ID, opendyslexic12FontFamily);
|
||||
renderer.insertFont(OPENDYSLEXIC_14_FONT_ID, opendyslexic14FontFamily);
|
||||
#endif // OMIT_FONTS
|
||||
renderer.insertFont(UI_10_FONT_ID, ui10FontFamily);
|
||||
renderer.insertFont(UI_12_FONT_ID, ui12FontFamily);
|
||||
|
||||
Reference in New Issue
Block a user