summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-03-31 09:34:49 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-03-31 09:34:49 (GMT)
commit194516f63398c04d356421d77cdf7b0519405113 (patch)
treee3bcf23309810726b234a0469394663b5f9e46c8
parent8b75855323218bf49d6108a9e5869be1bec68ce1 (diff)
allow custom glyphs for neofont
-rw-r--r--src/displayapp/fonts/neofont.c10
-rw-r--r--src/displayapp/screens/Symbols.h76
2 files changed, 79 insertions, 7 deletions
diff --git a/src/displayapp/fonts/neofont.c b/src/displayapp/fonts/neofont.c
index cfc8e72..b2728f3 100644
--- a/src/displayapp/fonts/neofont.c
+++ b/src/displayapp/fonts/neofont.c
@@ -313,7 +313,8 @@ static const uint8_t glyphs[][2] = {
/* Get the bitmap of `unicode_letter` from `font`. */
static const uint8_t * neofont0_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter)
{
- static const uint8_t spc[2] = {0,0};
+ static const uint8_t spc[] = { 0, 0 };
+ static uint8_t custom[2];
/* Your code here */
// /* The bitmap should be a continuous bitstream where
@@ -336,6 +337,13 @@ static const uint8_t * neofont0_glyph_bitmap_cb(const lv_font_t * font, uint32_t
return glyphs[36+(x-symbols)];
}
}
+
+ if ((0xF0000 < unicode_letter) && (unicode_letter < 0xF7FFF)) {
+ custom[0] = unicode_letter;
+ custom[1] = (unicode_letter >> 7);
+ return custom;
+ }
+
return glyphs[sizeof(glyphs)/sizeof(glyphs[0])-1];
}
diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h
index 928bcd7..faca4da 100644
--- a/src/displayapp/screens/Symbols.h
+++ b/src/displayapp/screens/Symbols.h
@@ -1,16 +1,80 @@
#pragma once
+ // For neofont:
+ // Layout for 3-byte codes: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+ // U+F0000: 11110011 10110000 000000 000000
+ // Neofont glyph: 11110011 10110zzz zzzzyy yyyyyy
+ // CDD DEEEAA ABBBCC
+ // \xF3 \xB[0-7] \x[8-B]. \x[8-B].
+ // "\xF3\xB5\x80\x97"
+
+// h + (g<<1) + (f<<2) + (e<<3) + (d << 4) + (c << 5) + (b << 6) + (a << 7), \
+// 0 + (o<<1) + (n<<2) + (m<<3) + (l << 4) + (k << 5) + (j << 6) + (i << 7) \
+
+#define G( \
+ a,b,c, \
+ d,e,f, \
+ g,h,i, \
+ j,k,l, \
+ m,n,o \
+) { \
+ 0xF3, \
+ 0xB0 | (i<<2) | (j << 1) | k, \
+ 0xB0 | (l<<5) | (m<<4) | (n<<3) | (o<<2) | (a<<1) | b, \
+ 0xB0 | (c<<5) | (d<<4) | (e<<3) | (f<<2) | (g<<1) | h, \
+ 0 \
+}
+
+#define X 1
+#define _ 0
+
namespace Pinetime {
namespace Applications {
namespace Screens {
namespace Symbols {
static constexpr const char* none = "";
- static constexpr const char* batteryFull = "\xEF\x89\x80";
- static constexpr const char* batteryEmpty = "\xEF\x89\x84";
- static constexpr const char* batteryThreeQuarter = "\xEF\x89\x81";
- static constexpr const char* batteryHalf = "\xEF\x89\x82";
- static constexpr const char* batteryOneQuarter = "\xEF\x89\x83";
- static constexpr const char* heartBeat = "\xEF\x88\x9E";
+ static constexpr const char* batteryFull =
+ // "\xEF\x89\x80";
+ G(_, X, _,
+ X, X, X,
+ X, X, X,
+ X, X, X,
+ X, X, X);
+ static constexpr const char* batteryEmpty =
+ // "\xEF\x89\x84";
+ G(_, X, _,
+ X, _, X,
+ X, _, X,
+ X, _, X,
+ X, X, X);
+ static constexpr const char* batteryThreeQuarter =
+ // Was: "\xEF\x89\x81";
+ G(_, X, _,
+ X, X, X,
+ X, _, X,
+ X, X, X,
+ X, X, X);
+ static constexpr const char* batteryHalf =
+ // Was: "\xEF\x89\x82";
+ G(_, X, _,
+ X, _, X,
+ X, X, X,
+ X, X, X,
+ X, X, X);
+ static constexpr const char* batteryOneQuarter =
+ // Was: "\xEF\x89\x83";
+ G(_, X, _,
+ X, _, X,
+ X, _, X,
+ X, X, X,
+ X, X, X);
+ static constexpr const char* heartBeat =
+ // Was: "\xEF\x88\x9E"
+ G(_, _, _,
+ X, _, X,
+ X, X, X,
+ _, X, _,
+ _, _, _);
static constexpr const char* bluetoothFull = "\xEF\x8A\x93";
static constexpr const char* bluetooth = "\xEF\x8A\x94";
static constexpr const char* plug = "\xEF\x87\xA6";