Add Open Dyslexic font and settings to change font size and family
This commit is contained in:
parent
fd2716a6f4
commit
7eaa717d3b
1681
lib/EpdFont/builtinFonts/aleo_12_bold.h
Normal file
1681
lib/EpdFont/builtinFonts/aleo_12_bold.h
Normal file
File diff suppressed because it is too large
Load Diff
1756
lib/EpdFont/builtinFonts/aleo_12_bolditalic.h
Normal file
1756
lib/EpdFont/builtinFonts/aleo_12_bolditalic.h
Normal file
File diff suppressed because it is too large
Load Diff
1649
lib/EpdFont/builtinFonts/aleo_12_italic.h
Normal file
1649
lib/EpdFont/builtinFonts/aleo_12_italic.h
Normal file
File diff suppressed because it is too large
Load Diff
1597
lib/EpdFont/builtinFonts/aleo_12_regular.h
Normal file
1597
lib/EpdFont/builtinFonts/aleo_12_regular.h
Normal file
File diff suppressed because it is too large
Load Diff
2621
lib/EpdFont/builtinFonts/aleo_16_bold.h
Normal file
2621
lib/EpdFont/builtinFonts/aleo_16_bold.h
Normal file
File diff suppressed because it is too large
Load Diff
2736
lib/EpdFont/builtinFonts/aleo_16_bolditalic.h
Normal file
2736
lib/EpdFont/builtinFonts/aleo_16_bolditalic.h
Normal file
File diff suppressed because it is too large
Load Diff
2556
lib/EpdFont/builtinFonts/aleo_16_italic.h
Normal file
2556
lib/EpdFont/builtinFonts/aleo_16_italic.h
Normal file
File diff suppressed because it is too large
Load Diff
2446
lib/EpdFont/builtinFonts/aleo_16_regular.h
Normal file
2446
lib/EpdFont/builtinFonts/aleo_16_regular.h
Normal file
File diff suppressed because it is too large
Load Diff
3170
lib/EpdFont/builtinFonts/aleo_18_bold.h
Normal file
3170
lib/EpdFont/builtinFonts/aleo_18_bold.h
Normal file
File diff suppressed because it is too large
Load Diff
3330
lib/EpdFont/builtinFonts/aleo_18_bolditalic.h
Normal file
3330
lib/EpdFont/builtinFonts/aleo_18_bolditalic.h
Normal file
File diff suppressed because it is too large
Load Diff
3107
lib/EpdFont/builtinFonts/aleo_18_italic.h
Normal file
3107
lib/EpdFont/builtinFonts/aleo_18_italic.h
Normal file
File diff suppressed because it is too large
Load Diff
2967
lib/EpdFont/builtinFonts/aleo_18_regular.h
Normal file
2967
lib/EpdFont/builtinFonts/aleo_18_regular.h
Normal file
File diff suppressed because it is too large
Load Diff
39
lib/EpdFont/builtinFonts/all.h
Normal file
39
lib/EpdFont/builtinFonts/all.h
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <builtinFonts/aleo_12_bold.h>
|
||||
#include <builtinFonts/aleo_12_bolditalic.h>
|
||||
#include <builtinFonts/aleo_12_italic.h>
|
||||
#include <builtinFonts/aleo_12_regular.h>
|
||||
#include <builtinFonts/aleo_14_bold.h>
|
||||
#include <builtinFonts/aleo_14_bolditalic.h>
|
||||
#include <builtinFonts/aleo_14_italic.h>
|
||||
#include <builtinFonts/aleo_14_regular.h>
|
||||
#include <builtinFonts/aleo_16_bold.h>
|
||||
#include <builtinFonts/aleo_16_bolditalic.h>
|
||||
#include <builtinFonts/aleo_16_italic.h>
|
||||
#include <builtinFonts/aleo_16_regular.h>
|
||||
#include <builtinFonts/aleo_18_bold.h>
|
||||
#include <builtinFonts/aleo_18_bolditalic.h>
|
||||
#include <builtinFonts/aleo_18_italic.h>
|
||||
#include <builtinFonts/aleo_18_regular.h>
|
||||
#include <builtinFonts/opendyslexic_10_bold.h>
|
||||
#include <builtinFonts/opendyslexic_10_bolditalic.h>
|
||||
#include <builtinFonts/opendyslexic_10_italic.h>
|
||||
#include <builtinFonts/opendyslexic_10_regular.h>
|
||||
#include <builtinFonts/opendyslexic_12_bold.h>
|
||||
#include <builtinFonts/opendyslexic_12_bolditalic.h>
|
||||
#include <builtinFonts/opendyslexic_12_italic.h>
|
||||
#include <builtinFonts/opendyslexic_12_regular.h>
|
||||
#include <builtinFonts/opendyslexic_14_bold.h>
|
||||
#include <builtinFonts/opendyslexic_14_bolditalic.h>
|
||||
#include <builtinFonts/opendyslexic_14_italic.h>
|
||||
#include <builtinFonts/opendyslexic_14_regular.h>
|
||||
#include <builtinFonts/opendyslexic_8_bold.h>
|
||||
#include <builtinFonts/opendyslexic_8_bolditalic.h>
|
||||
#include <builtinFonts/opendyslexic_8_italic.h>
|
||||
#include <builtinFonts/opendyslexic_8_regular.h>
|
||||
#include <builtinFonts/pixelarial14.h>
|
||||
#include <builtinFonts/ubuntu_10_bold.h>
|
||||
#include <builtinFonts/ubuntu_10_regular.h>
|
||||
#include <builtinFonts/ubuntu_12_bold.h>
|
||||
#include <builtinFonts/ubuntu_12_regular.h>
|
||||
2996
lib/EpdFont/builtinFonts/opendyslexic_10_bold.h
Normal file
2996
lib/EpdFont/builtinFonts/opendyslexic_10_bold.h
Normal file
File diff suppressed because it is too large
Load Diff
3480
lib/EpdFont/builtinFonts/opendyslexic_10_bolditalic.h
Normal file
3480
lib/EpdFont/builtinFonts/opendyslexic_10_bolditalic.h
Normal file
File diff suppressed because it is too large
Load Diff
3110
lib/EpdFont/builtinFonts/opendyslexic_10_italic.h
Normal file
3110
lib/EpdFont/builtinFonts/opendyslexic_10_italic.h
Normal file
File diff suppressed because it is too large
Load Diff
2729
lib/EpdFont/builtinFonts/opendyslexic_10_regular.h
Normal file
2729
lib/EpdFont/builtinFonts/opendyslexic_10_regular.h
Normal file
File diff suppressed because it is too large
Load Diff
3971
lib/EpdFont/builtinFonts/opendyslexic_12_bold.h
Normal file
3971
lib/EpdFont/builtinFonts/opendyslexic_12_bold.h
Normal file
File diff suppressed because it is too large
Load Diff
4659
lib/EpdFont/builtinFonts/opendyslexic_12_bolditalic.h
Normal file
4659
lib/EpdFont/builtinFonts/opendyslexic_12_bolditalic.h
Normal file
File diff suppressed because it is too large
Load Diff
4046
lib/EpdFont/builtinFonts/opendyslexic_12_italic.h
Normal file
4046
lib/EpdFont/builtinFonts/opendyslexic_12_italic.h
Normal file
File diff suppressed because it is too large
Load Diff
3552
lib/EpdFont/builtinFonts/opendyslexic_12_regular.h
Normal file
3552
lib/EpdFont/builtinFonts/opendyslexic_12_regular.h
Normal file
File diff suppressed because it is too large
Load Diff
5109
lib/EpdFont/builtinFonts/opendyslexic_14_bold.h
Normal file
5109
lib/EpdFont/builtinFonts/opendyslexic_14_bold.h
Normal file
File diff suppressed because it is too large
Load Diff
5984
lib/EpdFont/builtinFonts/opendyslexic_14_bolditalic.h
Normal file
5984
lib/EpdFont/builtinFonts/opendyslexic_14_bolditalic.h
Normal file
File diff suppressed because it is too large
Load Diff
5183
lib/EpdFont/builtinFonts/opendyslexic_14_italic.h
Normal file
5183
lib/EpdFont/builtinFonts/opendyslexic_14_italic.h
Normal file
File diff suppressed because it is too large
Load Diff
4447
lib/EpdFont/builtinFonts/opendyslexic_14_regular.h
Normal file
4447
lib/EpdFont/builtinFonts/opendyslexic_14_regular.h
Normal file
File diff suppressed because it is too large
Load Diff
2223
lib/EpdFont/builtinFonts/opendyslexic_8_bold.h
Normal file
2223
lib/EpdFont/builtinFonts/opendyslexic_8_bold.h
Normal file
File diff suppressed because it is too large
Load Diff
2507
lib/EpdFont/builtinFonts/opendyslexic_8_bolditalic.h
Normal file
2507
lib/EpdFont/builtinFonts/opendyslexic_8_bolditalic.h
Normal file
File diff suppressed because it is too large
Load Diff
2306
lib/EpdFont/builtinFonts/opendyslexic_8_italic.h
Normal file
2306
lib/EpdFont/builtinFonts/opendyslexic_8_italic.h
Normal file
File diff suppressed because it is too large
Load Diff
2041
lib/EpdFont/builtinFonts/opendyslexic_8_regular.h
Normal file
2041
lib/EpdFont/builtinFonts/opendyslexic_8_regular.h
Normal file
File diff suppressed because it is too large
Load Diff
94
lib/EpdFont/builtinFonts/source/OpenDyslexic/OFL.txt
Normal file
94
lib/EpdFont/builtinFonts/source/OpenDyslexic/OFL.txt
Normal file
@ -0,0 +1,94 @@
|
||||
Copyright (c) 2019-07-29, Abbie Gonzalez (https://abbiecod.es|support@abbiecod.es),
|
||||
with Reserved Font Name OpenDyslexic.
|
||||
Copyright (c) 12/2012 - 2019
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,7 +8,16 @@ echo "// The contents of this file are generated by ./lib/EpdFont/scripts/build-
|
||||
echo "#pragma once"
|
||||
echo ""
|
||||
|
||||
echo "#define READER_FONT_ID ($(
|
||||
echo "#define ALEO_12_FONT_ID ($(
|
||||
ruby -rdigest -e 'puts [
|
||||
"./aleo_12_regular.h",
|
||||
"./aleo_12_bold.h",
|
||||
"./aleo_12_bolditalic.h",
|
||||
"./aleo_12_italic.h",
|
||||
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
||||
))"
|
||||
|
||||
echo "#define ALEO_14_FONT_ID ($(
|
||||
ruby -rdigest -e 'puts [
|
||||
"./aleo_14_regular.h",
|
||||
"./aleo_14_bold.h",
|
||||
@ -17,6 +26,60 @@ ruby -rdigest -e 'puts [
|
||||
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
||||
))"
|
||||
|
||||
echo "#define ALEO_16_FONT_ID ($(
|
||||
ruby -rdigest -e 'puts [
|
||||
"./aleo_16_regular.h",
|
||||
"./aleo_16_bold.h",
|
||||
"./aleo_16_bolditalic.h",
|
||||
"./aleo_16_italic.h",
|
||||
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
||||
))"
|
||||
|
||||
echo "#define ALEO_18_FONT_ID ($(
|
||||
ruby -rdigest -e 'puts [
|
||||
"./aleo_18_regular.h",
|
||||
"./aleo_18_bold.h",
|
||||
"./aleo_18_bolditalic.h",
|
||||
"./aleo_18_italic.h",
|
||||
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
||||
))"
|
||||
|
||||
echo "#define OPENDYSLEXIC_8_FONT_ID ($(
|
||||
ruby -rdigest -e 'puts [
|
||||
"./opendyslexic_8_regular.h",
|
||||
"./opendyslexic_8_bold.h",
|
||||
"./opendyslexic_8_bolditalic.h",
|
||||
"./opendyslexic_8_italic.h",
|
||||
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
||||
))"
|
||||
|
||||
echo "#define OPENDYSLEXIC_10_FONT_ID ($(
|
||||
ruby -rdigest -e 'puts [
|
||||
"./opendyslexic_10_regular.h",
|
||||
"./opendyslexic_10_bold.h",
|
||||
"./opendyslexic_10_bolditalic.h",
|
||||
"./opendyslexic_10_italic.h",
|
||||
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
||||
))"
|
||||
|
||||
echo "#define OPENDYSLEXIC_12_FONT_ID ($(
|
||||
ruby -rdigest -e 'puts [
|
||||
"./opendyslexic_12_regular.h",
|
||||
"./opendyslexic_12_bold.h",
|
||||
"./opendyslexic_12_bolditalic.h",
|
||||
"./opendyslexic_12_italic.h",
|
||||
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
||||
))"
|
||||
|
||||
echo "#define OPENDYSLEXIC_14_FONT_ID ($(
|
||||
ruby -rdigest -e 'puts [
|
||||
"./opendyslexic_14_regular.h",
|
||||
"./opendyslexic_14_bold.h",
|
||||
"./opendyslexic_14_bolditalic.h",
|
||||
"./opendyslexic_14_italic.h",
|
||||
].map{|f| Digest::SHA256.hexdigest(File.read(f)).to_i(16) }.sum % (2 ** 32) - (2 ** 31)'
|
||||
))"
|
||||
|
||||
echo "#define UI_10_FONT_ID ($(
|
||||
ruby -rdigest -e 'puts [
|
||||
"./ubuntu_10_regular.h",
|
||||
|
||||
42
lib/EpdFont/scripts/convert-builtin-fonts.sh
Executable file
42
lib/EpdFont/scripts/convert-builtin-fonts.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
READER_FONT_STYLES=("Regular" "Italic" "Bold" "BoldItalic")
|
||||
ALEO_FONT_SIZES=(12 14 16 18)
|
||||
OPENDYSLEXIC_FONT_SIZES=(8 10 12 14)
|
||||
|
||||
for size in ${ALEO_FONT_SIZES[@]}; do
|
||||
for style in ${READER_FONT_STYLES[@]}; do
|
||||
font_name="aleo_${size}_$(echo $style | tr '[:upper:]' '[:lower:]')"
|
||||
font_path="../builtinFonts/source/Aleo/Aleo-${style}.ttf"
|
||||
output_path="../builtinFonts/${font_name}.h"
|
||||
python fontconvert.py $font_name $size $font_path --2bit > $output_path
|
||||
echo "Generated $output_path"
|
||||
done
|
||||
done
|
||||
|
||||
for size in ${OPENDYSLEXIC_FONT_SIZES[@]}; do
|
||||
for style in ${READER_FONT_STYLES[@]}; do
|
||||
font_name="opendyslexic_${size}_$(echo $style | tr '[:upper:]' '[:lower:]')"
|
||||
font_path="../builtinFonts/source/OpenDyslexic/OpenDyslexic-${style}.otf"
|
||||
output_path="../builtinFonts/${font_name}.h"
|
||||
python fontconvert.py $font_name $size $font_path --2bit > $output_path
|
||||
echo "Generated $output_path"
|
||||
done
|
||||
done
|
||||
|
||||
UI_FONT_SIZES=(10 12)
|
||||
UI_FONT_STYLES=("Regular" "Bold")
|
||||
|
||||
for size in ${UI_FONT_SIZES[@]}; do
|
||||
for style in ${UI_FONT_STYLES[@]}; do
|
||||
font_name="ubuntu_${size}_$(echo $style | tr '[:upper:]' '[:lower:]')"
|
||||
font_path="../builtinFonts/source/Ubuntu/Ubuntu-${style}.ttf"
|
||||
output_path="../builtinFonts/${font_name}.h"
|
||||
python fontconvert.py $font_name $size $font_path > $output_path
|
||||
echo "Generated $output_path"
|
||||
done
|
||||
done
|
||||
@ -4,13 +4,15 @@
|
||||
#include <SDCardManager.h>
|
||||
#include <Serialization.h>
|
||||
|
||||
#include "fontIds.h"
|
||||
|
||||
// Initialize the static instance
|
||||
CrossPointSettings CrossPointSettings::instance;
|
||||
|
||||
namespace {
|
||||
constexpr uint8_t SETTINGS_FILE_VERSION = 1;
|
||||
// Increment this when adding new persisted settings fields
|
||||
constexpr uint8_t SETTINGS_COUNT = 7;
|
||||
constexpr uint8_t SETTINGS_COUNT = 9;
|
||||
constexpr char SETTINGS_FILE[] = "/.crosspoint/settings.bin";
|
||||
} // namespace
|
||||
|
||||
@ -32,6 +34,8 @@ bool CrossPointSettings::saveToFile() const {
|
||||
serialization::writePod(outputFile, orientation);
|
||||
serialization::writePod(outputFile, frontButtonLayout);
|
||||
serialization::writePod(outputFile, sideButtonLayout);
|
||||
serialization::writePod(outputFile, fontFamily);
|
||||
serialization::writePod(outputFile, fontSize);
|
||||
outputFile.close();
|
||||
|
||||
Serial.printf("[%lu] [CPS] Settings saved to file\n", millis());
|
||||
@ -72,9 +76,43 @@ bool CrossPointSettings::loadFromFile() {
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, sideButtonLayout);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, fontFamily);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, fontSize);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
} while (false);
|
||||
|
||||
inputFile.close();
|
||||
Serial.printf("[%lu] [CPS] Settings loaded from file\n", millis());
|
||||
return true;
|
||||
}
|
||||
|
||||
int CrossPointSettings::getReaderFontId() const {
|
||||
switch (fontFamily) {
|
||||
case ALEO:
|
||||
default:
|
||||
switch (fontSize) {
|
||||
case SMALL:
|
||||
return ALEO_12_FONT_ID;
|
||||
case MEDIUM:
|
||||
default:
|
||||
return ALEO_14_FONT_ID;
|
||||
case LARGE:
|
||||
return ALEO_16_FONT_ID;
|
||||
case EXTRA_LARGE:
|
||||
return ALEO_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,11 @@ class CrossPointSettings {
|
||||
// Swapped: Next, Previous
|
||||
enum SIDE_BUTTON_LAYOUT { PREV_NEXT = 0, NEXT_PREV = 1 };
|
||||
|
||||
// Font family options
|
||||
enum FONT_FAMILY { ALEO = 0, OPENDYSLEXIC = 1 };
|
||||
// Font size options
|
||||
enum FONT_SIZE { SMALL = 0, MEDIUM = 1, LARGE = 2, EXTRA_LARGE = 3 };
|
||||
|
||||
// Sleep screen settings
|
||||
uint8_t sleepScreen = DARK;
|
||||
// Status bar settings
|
||||
@ -53,6 +58,10 @@ class CrossPointSettings {
|
||||
uint8_t frontButtonLayout = BACK_CONFIRM_LEFT_RIGHT;
|
||||
// Side button layout
|
||||
uint8_t sideButtonLayout = PREV_NEXT;
|
||||
// Font family
|
||||
uint8_t fontFamily = ALEO;
|
||||
// Font size
|
||||
uint8_t fontSize = MEDIUM;
|
||||
|
||||
~CrossPointSettings() = default;
|
||||
|
||||
@ -60,6 +69,7 @@ class CrossPointSettings {
|
||||
static CrossPointSettings& getInstance() { return instance; }
|
||||
|
||||
uint16_t getPowerButtonDuration() const { return shortPwrBtn ? 10 : 400; }
|
||||
int getReaderFontId() const;
|
||||
|
||||
bool saveToFile() const;
|
||||
bool loadFromFile();
|
||||
|
||||
@ -255,8 +255,8 @@ void EpubReaderActivity::renderScreen() {
|
||||
const auto viewportWidth = renderer.getScreenWidth() - orientedMarginLeft - orientedMarginRight;
|
||||
const auto viewportHeight = renderer.getScreenHeight() - orientedMarginTop - orientedMarginBottom;
|
||||
|
||||
if (!section->loadSectionFile(READER_FONT_ID, lineCompression, SETTINGS.extraParagraphSpacing, viewportWidth,
|
||||
viewportHeight)) {
|
||||
if (!section->loadSectionFile(SETTINGS.getReaderFontId(), lineCompression, SETTINGS.extraParagraphSpacing,
|
||||
viewportWidth, viewportHeight)) {
|
||||
Serial.printf("[%lu] [ERS] Cache not found, building...\n", millis());
|
||||
|
||||
// Progress bar dimensions
|
||||
@ -299,8 +299,8 @@ void EpubReaderActivity::renderScreen() {
|
||||
renderer.displayBuffer(EInkDisplay::FAST_REFRESH);
|
||||
};
|
||||
|
||||
if (!section->createSectionFile(READER_FONT_ID, lineCompression, SETTINGS.extraParagraphSpacing, viewportWidth,
|
||||
viewportHeight, progressSetup, progressCallback)) {
|
||||
if (!section->createSectionFile(SETTINGS.getReaderFontId(), lineCompression, SETTINGS.extraParagraphSpacing,
|
||||
viewportWidth, viewportHeight, progressSetup, progressCallback)) {
|
||||
Serial.printf("[%lu] [ERS] Failed to persist page data to SD\n", millis());
|
||||
section.reset();
|
||||
return;
|
||||
@ -362,7 +362,7 @@ void EpubReaderActivity::renderScreen() {
|
||||
void EpubReaderActivity::renderContents(std::unique_ptr<Page> page, const int orientedMarginTop,
|
||||
const int orientedMarginRight, const int orientedMarginBottom,
|
||||
const int orientedMarginLeft) {
|
||||
page->render(renderer, READER_FONT_ID, orientedMarginLeft, orientedMarginTop);
|
||||
page->render(renderer, SETTINGS.getReaderFontId(), orientedMarginLeft, orientedMarginTop);
|
||||
renderStatusBar(orientedMarginRight, orientedMarginBottom, orientedMarginLeft);
|
||||
if (pagesUntilFullRefresh <= 1) {
|
||||
renderer.displayBuffer(EInkDisplay::HALF_REFRESH);
|
||||
@ -380,13 +380,13 @@ void EpubReaderActivity::renderContents(std::unique_ptr<Page> page, const int or
|
||||
{
|
||||
renderer.clearScreen(0x00);
|
||||
renderer.setRenderMode(GfxRenderer::GRAYSCALE_LSB);
|
||||
page->render(renderer, READER_FONT_ID, orientedMarginLeft, orientedMarginTop);
|
||||
page->render(renderer, SETTINGS.getReaderFontId(), orientedMarginLeft, orientedMarginTop);
|
||||
renderer.copyGrayscaleLsbBuffers();
|
||||
|
||||
// Render and copy to MSB buffer
|
||||
renderer.clearScreen(0x00);
|
||||
renderer.setRenderMode(GfxRenderer::GRAYSCALE_MSB);
|
||||
page->render(renderer, READER_FONT_ID, orientedMarginLeft, orientedMarginTop);
|
||||
page->render(renderer, SETTINGS.getReaderFontId(), orientedMarginLeft, orientedMarginTop);
|
||||
renderer.copyGrayscaleMsbBuffers();
|
||||
|
||||
// display grayscale part
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
// Define the static settings list
|
||||
namespace {
|
||||
constexpr int settingsCount = 8;
|
||||
constexpr int settingsCount = 10;
|
||||
const SettingInfo settingsList[settingsCount] = {
|
||||
// Should match with SLEEP_SCREEN_MODE
|
||||
{"Sleep Screen", SettingType::ENUM, &CrossPointSettings::sleepScreen, {"Dark", "Light", "Custom", "Cover"}},
|
||||
@ -28,6 +28,8 @@ const SettingInfo settingsList[settingsCount] = {
|
||||
SettingType::ENUM,
|
||||
&CrossPointSettings::sideButtonLayout,
|
||||
{"Prev, Next", "Next, Prev"}},
|
||||
{"Reader Font Family", SettingType::ENUM, &CrossPointSettings::fontFamily, {"Aleo", "Open Dyslexic"}},
|
||||
{"Reader Font Size", SettingType::ENUM, &CrossPointSettings::fontSize, {"Small", "Medium", "Large", "X Large"}},
|
||||
{"Check for updates", SettingType::ACTION, nullptr, {}},
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
// The contents of this file are generated by ./lib/EpdFont/scripts/build-font-ids.sh
|
||||
#pragma once
|
||||
|
||||
#define READER_FONT_ID (-1667320299)
|
||||
#define ALEO_12_FONT_ID (834966729)
|
||||
#define ALEO_14_FONT_ID (-1667320299)
|
||||
#define ALEO_16_FONT_ID (-1337958100)
|
||||
#define ALEO_18_FONT_ID (-268969776)
|
||||
#define OPENDYSLEXIC_8_FONT_ID (-331738429)
|
||||
#define OPENDYSLEXIC_10_FONT_ID (-206739437)
|
||||
#define OPENDYSLEXIC_12_FONT_ID (-263369585)
|
||||
#define OPENDYSLEXIC_14_FONT_ID (-1978357942)
|
||||
#define UI_10_FONT_ID (-381091506)
|
||||
#define UI_12_FONT_ID (-2011443791)
|
||||
#define SMALL_FONT_ID (1197804093)
|
||||
|
||||
59
src/main.cpp
59
src/main.cpp
@ -5,15 +5,7 @@
|
||||
#include <InputManager.h>
|
||||
#include <SDCardManager.h>
|
||||
#include <SPI.h>
|
||||
#include <builtinFonts/aleo_14_bold.h>
|
||||
#include <builtinFonts/aleo_14_bolditalic.h>
|
||||
#include <builtinFonts/aleo_14_italic.h>
|
||||
#include <builtinFonts/aleo_14_regular.h>
|
||||
#include <builtinFonts/pixelarial14.h>
|
||||
#include <builtinFonts/ubuntu_10_regular.h>
|
||||
#include <builtinFonts/ubuntu_10_bold.h>
|
||||
#include <builtinFonts/ubuntu_12_regular.h>
|
||||
#include <builtinFonts/ubuntu_12_bold.h>
|
||||
#include <builtinFonts/all.h>
|
||||
|
||||
#include "Battery.h"
|
||||
#include "CrossPointSettings.h"
|
||||
@ -48,11 +40,51 @@ GfxRenderer renderer(einkDisplay);
|
||||
Activity* currentActivity;
|
||||
|
||||
// Fonts
|
||||
EpdFont aleo12RegularFont(&aleo_12_regular);
|
||||
EpdFont aleo12BoldFont(&aleo_12_bold);
|
||||
EpdFont aleo12ItalicFont(&aleo_12_italic);
|
||||
EpdFont aleo12BoldItalicFont(&aleo_12_bolditalic);
|
||||
EpdFontFamily aleo12FontFamily(&aleo12RegularFont, &aleo12BoldFont, &aleo12ItalicFont, &aleo12BoldItalicFont);
|
||||
EpdFont aleo14RegularFont(&aleo_14_regular);
|
||||
EpdFont aleo14BoldFont(&aleo_14_bold);
|
||||
EpdFont aleo14ItalicFont(&aleo_14_italic);
|
||||
EpdFont aleo14BoldItalicFont(&aleo_14_bolditalic);
|
||||
EpdFontFamily aleo14FontFamily(&aleo14RegularFont, &aleo14BoldFont, &aleo14ItalicFont, &aleo14BoldItalicFont);
|
||||
EpdFont aleo16RegularFont(&aleo_16_regular);
|
||||
EpdFont aleo16BoldFont(&aleo_16_bold);
|
||||
EpdFont aleo16ItalicFont(&aleo_16_italic);
|
||||
EpdFont aleo16BoldItalicFont(&aleo_16_bolditalic);
|
||||
EpdFontFamily aleo16FontFamily(&aleo16RegularFont, &aleo16BoldFont, &aleo16ItalicFont, &aleo16BoldItalicFont);
|
||||
EpdFont aleo18RegularFont(&aleo_18_regular);
|
||||
EpdFont aleo18BoldFont(&aleo_18_bold);
|
||||
EpdFont aleo18ItalicFont(&aleo_18_italic);
|
||||
EpdFont aleo18BoldItalicFont(&aleo_18_bolditalic);
|
||||
EpdFontFamily aleo18FontFamily(&aleo18RegularFont, &aleo18BoldFont, &aleo18ItalicFont, &aleo18BoldItalicFont);
|
||||
|
||||
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);
|
||||
|
||||
EpdFont smallFont(&pixelarial14);
|
||||
EpdFontFamily smallFontFamily(&smallFont);
|
||||
@ -170,7 +202,14 @@ void onGoHome() {
|
||||
void setupDisplayAndFonts() {
|
||||
einkDisplay.begin();
|
||||
Serial.printf("[%lu] [ ] Display initialized\n", millis());
|
||||
renderer.insertFont(READER_FONT_ID, aleo14FontFamily);
|
||||
renderer.insertFont(ALEO_12_FONT_ID, aleo12FontFamily);
|
||||
renderer.insertFont(ALEO_14_FONT_ID, aleo14FontFamily);
|
||||
renderer.insertFont(ALEO_16_FONT_ID, aleo16FontFamily);
|
||||
renderer.insertFont(ALEO_18_FONT_ID, aleo18FontFamily);
|
||||
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);
|
||||
renderer.insertFont(UI_10_FONT_ID, ui10FontFamily);
|
||||
renderer.insertFont(UI_12_FONT_ID, ui12FontFamily);
|
||||
renderer.insertFont(SMALL_FONT_ID, smallFontFamily);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user