fix(bookerly): use fallback anchor for bookerlyStyle field insertion in fresh repo
This commit is contained in:
1 parent
d3d443ce7f
commit
5c4fb9143e
2 files changed
+10
-89
No files matched your search
@@ -1,86 +0,0 @@
|
|||||||
#include "SmallerFontsPlugin.h"
|
|
||||||
#include "fontIds.h"
|
|
||||||
|
|
||||||
namespace SmallerFontsPlugin {
|
|
||||||
|
|
||||||
const char* modeName(SmallerFontsMode mode) {
|
|
||||||
switch (mode) {
|
|
||||||
case SmallerFontsMode::SMALLER: return "Smaller";
|
|
||||||
case SmallerFontsMode::SMALLEST: return "Smallest";
|
|
||||||
default: return "Disabled";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int resolveReaderFontId(int baseFontId, SmallerFontsMode mode) {
|
|
||||||
if (mode == SmallerFontsMode::MODE_OFF) return baseFontId;
|
|
||||||
|
|
||||||
#ifdef BOOKERLY_8_FONT_ID
|
|
||||||
if (baseFontId == BOOKERLY_8_FONT_ID) return BOOKERLY_8_FONT_ID;
|
|
||||||
if (baseFontId == BOOKERLY_10_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return BOOKERLY_8_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return BOOKERLY_8_FONT_ID;
|
|
||||||
}
|
|
||||||
if (baseFontId == BOOKERLY_12_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return BOOKERLY_10_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return BOOKERLY_8_FONT_ID;
|
|
||||||
}
|
|
||||||
if (baseFontId == BOOKERLY_14_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return BOOKERLY_12_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return BOOKERLY_10_FONT_ID;
|
|
||||||
}
|
|
||||||
if (baseFontId == BOOKERLY_16_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return BOOKERLY_14_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return BOOKERLY_12_FONT_ID;
|
|
||||||
}
|
|
||||||
if (baseFontId == BOOKERLY_18_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return BOOKERLY_16_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return BOOKERLY_14_FONT_ID;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (baseFontId == NOTOSERIF_12_FONT_ID) return NOTOSERIF_12_FONT_ID;
|
|
||||||
if (baseFontId == NOTOSERIF_14_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return NOTOSERIF_12_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return NOTOSERIF_12_FONT_ID;
|
|
||||||
}
|
|
||||||
if (baseFontId == NOTOSERIF_16_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return NOTOSERIF_14_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return NOTOSERIF_12_FONT_ID;
|
|
||||||
}
|
|
||||||
if (baseFontId == NOTOSERIF_18_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return NOTOSERIF_16_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return NOTOSERIF_14_FONT_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (baseFontId == NOTOSANS_12_FONT_ID) return NOTOSANS_12_FONT_ID;
|
|
||||||
if (baseFontId == NOTOSANS_14_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return NOTOSANS_12_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return NOTOSANS_12_FONT_ID;
|
|
||||||
}
|
|
||||||
if (baseFontId == NOTOSANS_16_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return NOTOSANS_14_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return NOTOSANS_12_FONT_ID;
|
|
||||||
}
|
|
||||||
if (baseFontId == NOTOSANS_18_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return NOTOSANS_16_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return NOTOSANS_14_FONT_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (baseFontId == OPENDYSLEXIC_8_FONT_ID) return OPENDYSLEXIC_8_FONT_ID;
|
|
||||||
if (baseFontId == OPENDYSLEXIC_10_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return OPENDYSLEXIC_8_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return OPENDYSLEXIC_8_FONT_ID;
|
|
||||||
}
|
|
||||||
if (baseFontId == OPENDYSLEXIC_12_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return OPENDYSLEXIC_10_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return OPENDYSLEXIC_8_FONT_ID;
|
|
||||||
}
|
|
||||||
if (baseFontId == OPENDYSLEXIC_14_FONT_ID) {
|
|
||||||
if (mode == SmallerFontsMode::SMALLER) return OPENDYSLEXIC_12_FONT_ID;
|
|
||||||
if (mode == SmallerFontsMode::SMALLEST) return OPENDYSLEXIC_10_FONT_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseFontId;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -181,10 +181,17 @@ def patch_cross_point_settings_h(repo_dir):
|
|||||||
'enum FONT_FAMILY { NOTOSERIF = 0, NOTOSANS = 1, OPENDYSLEXIC = 2, BOOKERLY = 3, FONT_FAMILY_COUNT };'
|
'enum FONT_FAMILY { NOTOSERIF = 0, NOTOSANS = 1, OPENDYSLEXIC = 2, BOOKERLY = 3, FONT_FAMILY_COUNT };'
|
||||||
)
|
)
|
||||||
|
|
||||||
content = content.replace(
|
if 'uint8_t bookerlyStyle' not in content:
|
||||||
|
anchor = None
|
||||||
|
for candidate in [
|
||||||
' uint8_t smallerFontsMode = 0;',
|
' uint8_t smallerFontsMode = 0;',
|
||||||
' uint8_t smallerFontsMode = 0;\n uint8_t bookerlyStyle = 0;'
|
' uint8_t imageRendering = IMAGES_DISPLAY;',
|
||||||
)
|
]:
|
||||||
|
if candidate in content:
|
||||||
|
anchor = candidate
|
||||||
|
break
|
||||||
|
if anchor:
|
||||||
|
content = content.replace(anchor, anchor + '\n uint8_t bookerlyStyle = 0;')
|
||||||
|
|
||||||
write_file(path, content)
|
write_file(path, content)
|
||||||
print(" CrossPointSettings.h patched.")
|
print(" CrossPointSettings.h patched.")
|
||||||
|
|||||||
Reference in new issue
Block a user