diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-04-10 06:26:41 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-04-10 06:27:15 (GMT) |
| commit | f85ecbc7bff3cb7c827380c96ff00b1de3857d76 (patch) | |
| tree | cf9713fd9d318e937fb8c585c39ad5c1102207ab /src/displayapp | |
| parent | 910a14a13151e5fc0d08364ed39368778bb3dd5d (diff) | |
Add neofont{0|1|15|2|3}[mono]
Diffstat (limited to 'src/displayapp')
| -rw-r--r-- | src/displayapp/fonts/neofont.c | 661 |
1 files changed, 643 insertions, 18 deletions
diff --git a/src/displayapp/fonts/neofont.c b/src/displayapp/fonts/neofont.c index 25fa3de..9e8981e 100644 --- a/src/displayapp/fonts/neofont.c +++ b/src/displayapp/fonts/neofont.c @@ -242,6 +242,12 @@ static const uint8_t glyphs[][2] = { X, X, X ), + G( _, X, _, + _, X, _, + _, X, _, + _, X, _, + _, X, _ ), + G( _, _, _, _, _, _, X, X, X, @@ -297,12 +303,6 @@ static const uint8_t glyphs[][2] = { X, _, _, _, _, X ), - G( _, _, _, - _, X, _, - X, X, X, - _, X, _, - _, _, _ ), - G( _, X, _, X, X, X, _, X, _, @@ -321,9 +321,29 @@ static const uint8_t glyphs[][2] = { #undef _ #undef G -// This could be inline to save a few bytes... +/* Get info about glyph of `unicode_letter` in `font` font. + * Store the result in `dsc_out`. + * The next letter (`unicode_letter_next`) might be used to calculate the width required by this glyph (kerning) + */ +static bool neofont0mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ + /*Your code here*/ + + /* Store the result. + * For example ... + */ + dsc_out->adv_w = 4; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 5; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 3; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = 0; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = 0; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + /* 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 * neofont0mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { static const uint8_t spc[] = { 0, 0 }; static uint8_t custom[2]; @@ -342,7 +362,7 @@ static const uint8_t * neofont0_glyph_bitmap_cb(const lv_font_t * font, uint32_t } if (unicode_letter == ' ') { return spc; } - static const char *symbols = "-/:.,_?!%+#"; + static const char *symbols = "|-/:.,_?!%#"; if (unicode_letter < 0x80) { char*x = strchr(symbols,((uint8_t)unicode_letter)); if (x != NULL) { @@ -350,41 +370,245 @@ static const uint8_t * neofont0_glyph_bitmap_cb(const lv_font_t * font, uint32_t } } + switch (unicode_letter) { + case 0xB0: + return glyphs[sizeof(glyphs)/sizeof(glyphs[0])-1]; + } + if ((0xF0000 < unicode_letter) && (unicode_letter < 0xF7FFF)) { custom[0] = unicode_letter; custom[1] = (unicode_letter >> 7); return custom; } - switch (unicode_letter) { - case 0xB0: - return glyphs[sizeof(glyphs)/sizeof(glyphs[0])-1]; - } - return glyphs[sizeof(glyphs)/sizeof(glyphs[0])-2]; } -static bool neofont15_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +lv_font_t neofont0mono = { + .get_glyph_dsc = neofont0mono_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont0mono_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 6, /*The real line height where any text fits*/ + .base_line = 1, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool neofont1mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + /*Your code here*/ + + /* Store the result. + * For example ... + */ + + // ######..###### + // ##::::..::##:: + // ######..::##:: + // ::::##..::##:: + // ######..::##:: + + // ######..######.. + // ######..######.. + // ##::::..::##::.. + // ##::::..::##::.. + // ######..::##::.. + // ######..::##::.. + // ::::##..::##::.. + // ::::##..::##::.. + // ######..::##::.. + // ######..::##::.. + + dsc_out->adv_w = 8; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 10; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 6; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = 1; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -1; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + +#if 0 +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont1mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +{ + const uint8_t *u = neofont0mono_glyph_bitmap_cb(font, unicode_letter); + static uint8_t v[(10*10+7)/8]; + uint8_t u0 = u[0]; + uint8_t u1 = u[1]; + + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // .9 .8 .7 .6 .5 .4 .3 .2 .1 .0 + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // 19 18 17 16 15 14 13 12 11 10 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 29 28 27 26 25 24 23 22 21 20 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 39 38 37 36 35 34 33 32 31 30 + + // v[7] = 0x00; + + uint8_t a,b,c, d,e,f, g,h,i, j,k,l, m,n,o; + a = (u0>>7)&1; u0 <<= 1; + b = (u0>>7)&1; u0 <<= 1; + c = (u0>>7)&1; u0 <<= 1; + d = (u0>>7)&1; u0 <<= 1; + e = (u0>>7)&1; u0 <<= 1; + f = (u0>>7)&1; u0 <<= 1; + g = (u0>>7)&1; u0 <<= 1; + h = (u0>>7)&1; + i = (u1>>7)&1; u1 <<= 1; + j = (u1>>7)&1; u1 <<= 1; + k = (u1>>7)&1; u1 <<= 1; + l = (u1>>7)&1; u1 <<= 1; + m = (u1>>7)&1; u1 <<= 1; + n = (u1>>7)&1; u1 <<= 1; + o = (u1>>7)&1; + +#define P(a,b,c,d, e,f,g,h) ((a<<7)|(b<<6)|(c<<5)|(d<<4)|(e<<3)|(f<<2)|(g<<1)|h) + + v[0] = P(0,0,a,a,b,b,c,c); + v[1] = P(0,0,a,a,b,b,c,c); + v[2] = P(0,0,d,d,e,e,f,f); + v[3] = P(0,d,d,e,e,f,f,0); + v[4] = P(0,g,g,h,h,i,i,0); + v[5] = P(g,g,h,h,i,i,0,0); + v[6] = P(j,j,k,k,l,l,0,0); + v[7] = P(j,j,k,k,l,l,0,0); + v[8] = P(m,m,n,n,o,o,0,0); + v[9] = P(m,m,n,n,o,o,0,0); + +#undef P + + return v; /*Or NULL if not found*/ +} +#endif + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont1mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +{ + const uint8_t *u = neofont0mono_glyph_bitmap_cb(font, unicode_letter); + static uint8_t v[8]; + uint8_t u0 = u[0]; + uint8_t u1 = u[1]; + + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // .9 .8 .7 .6 .5 .4 .3 .2 .1 .0 + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // 19 18 17 16 15 14 13 12 11 10 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 29 28 27 26 25 24 23 22 21 20 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 39 38 37 36 35 34 33 32 31 30 + + // v[7] = 0x00; + uint8_t a,b,c, d,e,f, g,h,i, j,k,l, m,n,o; + a = (u0>>7)&1; u0 <<= 1; + b = (u0>>7)&1; u0 <<= 1; + c = (u0>>7)&1; u0 <<= 1; + d = (u0>>7)&1; u0 <<= 1; + e = (u0>>7)&1; u0 <<= 1; + f = (u0>>7)&1; u0 <<= 1; + g = (u0>>7)&1; u0 <<= 1; + h = (u0>>7)&1; + i = (u1>>7)&1; u1 <<= 1; + j = (u1>>7)&1; u1 <<= 1; + k = (u1>>7)&1; u1 <<= 1; + l = (u1>>7)&1; u1 <<= 1; + m = (u1>>7)&1; u1 <<= 1; + n = (u1>>7)&1; u1 <<= 1; + o = (u1>>7)&1; + +#define P(a,b,c,d, e,f,g,h) ((a<<7)|(b<<6)|(c<<5)|(d<<4)|(e<<3)|(f<<2)|(g<<1)|h) + + v[0] = P(a,a,b,b,c,c, + + a,a); + v[1] = P(b,b,c,c, + + d,d,e,e); + v[2] = P(f,f, + + d,d,e,e,f,f); + + v[3] = P(g,g,h,h,i,i, + + g,g); + v[4] = P(h,h,i,i, + + j,j,k,k); + v[5] = P(l,l, + + j,j,k,k,l,l); + + v[6] = P(m,m,n,n,o,o, + + m,m); + v[7] = P(n,n,o,o, + + 0,0,0,0); + +#undef P + + return v; /*Or NULL if not found*/ +} + +/*Describe the properties of a font*/ +lv_font_t neofont1mono = { + .get_glyph_dsc = neofont1mono_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont1mono_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 12, /*The real line height where any text fits*/ + .base_line = 2, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool neofont15mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ dsc_out->adv_w = 12; /*Horizontal space required by the glyph in [px]*/ dsc_out->box_h = 15; /*Height of the bitmap in [px]*/ dsc_out->box_w = 9; /*Width of the bitmap in [px]*/ dsc_out->ofs_x = 1; /*X offset of the bitmap in [pf]*/ - dsc_out->ofs_y = 0; /*Y offset of the bitmap measured from the as line*/ + dsc_out->ofs_y = -1; /*Y offset of the bitmap measured from the as line*/ dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ return true; /*true: glyph found; false: glyph was not found*/ } /* Get the bitmap of `unicode_letter` from `font`. */ -static const uint8_t * neofont15_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +static const uint8_t * neofont15mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { - const uint8_t *u = neofont0_glyph_bitmap_cb(font, unicode_letter); + const uint8_t *u = neofont0mono_glyph_bitmap_cb(font, unicode_letter); static uint8_t v[17]; uint8_t u0 = u[0]; uint8_t u1 = u[1]; + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // .9 .8 .7 .6 .5 .4 .3 .2 .1 .0 + // .. .. .. .. .2 .2 .1 .1 .0 .0 + // 19 18 17 16 15 14 13 12 11 10 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 29 28 27 26 25 24 23 22 21 20 + // .. .. .. .5 .5 .4 .4 .3 .3 .. + // 39 38 37 36 35 34 33 32 31 30 + + // v[7] = 0x00; + uint8_t a,b,c, d,e,f, g,h,i, j,k,l, m,n,o; a = (u0>>7)&1; u0 <<= 1; b = (u0>>7)&1; u0 <<= 1; @@ -445,6 +669,331 @@ static const uint8_t * neofont15_glyph_bitmap_cb(const lv_font_t * font, uint32_ } /*Describe the properties of a font*/ +lv_font_t neofont15mono = { + .get_glyph_dsc = neofont15mono_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont15mono_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 18, /*The real line height where any text fits*/ + .base_line = 2, + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +/* Get info about glyph of `unicode_letter` in `font` font. + * Store the result in `dsc_out`. + * The next letter (`unicode_letter_next`) might be used to calculate the width required by this glyph (kerning) + */ +static bool neofont2mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ + dsc_out->adv_w = 16; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 20; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 12; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = 2; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -2; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont2mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +{ + const uint8_t *u = neofont0mono_glyph_bitmap_cb(font, unicode_letter); + static uint8_t v[30]; + uint8_t u0 = u[0]; + uint8_t u1 = u[1]; + + uint8_t a,b,c, d,e,f, g,h,i, j,k,l, m,n,o; + a = (u0>>7)&1; u0 <<= 1; + b = (u0>>7)&1; u0 <<= 1; + c = (u0>>7)&1; u0 <<= 1; + d = (u0>>7)&1; u0 <<= 1; + e = (u0>>7)&1; u0 <<= 1; + f = (u0>>7)&1; u0 <<= 1; + g = (u0>>7)&1; u0 <<= 1; + h = (u0>>7)&1; + i = (u1>>7)&1; u1 <<= 1; + j = (u1>>7)&1; u1 <<= 1; + k = (u1>>7)&1; u1 <<= 1; + l = (u1>>7)&1; u1 <<= 1; + m = (u1>>7)&1; u1 <<= 1; + n = (u1>>7)&1; u1 <<= 1; + o = (u1>>7)&1; + +#define P(a,b) (a?0xf0:0)|(b?0x0f:0) + + v[0] = P(a,b); + v[1] = P(c, + a); + v[2] = P(b,c); + + v[3] = v[0]; v[4] = v[1]; v[5] = v[2]; + + v[6] = P(d,e); + v[7] = P(f, + d); + v[8] = P(e,f); + + v[9] = v[6]; v[10] = v[7]; v[11] = v[8]; + + v[12] = P(g,h); + v[13] = P(i, + g); + v[14] = P(h,i); + + v[15] = v[12]; v[16] = v[13]; v[17] = v[14]; + + v[18] = P(j,k); + v[19] = P(l, + j); + v[20] = P(k,l); + + v[21] = v[18]; v[22] = v[19]; v[23] = v[20]; + + v[24] = P(m,n); + v[25] = P(o, + m); + v[26] = P(n,o); + + v[27] = v[24]; v[28] = v[25]; v[29] = v[26]; + +#undef P + + return v; /*Or NULL if not found*/ +} + +/*Describe the properties of a font*/ +lv_font_t neofont2mono = { + .get_glyph_dsc = neofont2mono_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont2mono_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 24, /*The real line height where any text fits*/ + .base_line = 4, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +/* Get info about glyph of `unicode_letter` in `font` font. + * Store the result in `dsc_out`. + * The next letter (`unicode_letter_next`) might be used to calculate the width required by this glyph (kerning) + */ +static bool neofont3mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ + dsc_out->adv_w = 32; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 40; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 24; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = 4; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -4; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + return true; /*true: glyph found; false: glyph was not found*/ +} + +static void mono_bitmap_scale_4( + const uint8_t *u, uint8_t *v, unsigned int w, unsigned int h, + const uint8_t *u0, const uint8_t *u1, + const uint8_t *v0, const uint8_t *v1 +) { + unsigned int y = 0; + uint8_t U; + const uint8_t *V = v; + const uint8_t *v_line_end = &(v[w]); + const uint8_t *v_line_next = &(v[w<<2]); + for (;;) { + U = *u; + if (!(v0 <= v && v < v1)) { + // fprintf(stderr, "Overflow 0!\n"); + return; + } + *v = ( ((U&0x80) ? 0xf0 : 0) | ((U&0x40) ? 0x0f : 0) ); + U <<= 2; v++; + if (!(v0 <= v && v < v1)) { return; } + *v = ( ((U&0x80) ? 0xf0 : 0) | ((U&0x40) ? 0x0f : 0) ); + U <<= 2; v++; + if (v >= v_line_end) { + while (v < v_line_next) { + if (!(v0 <= v && v < v1)) { + // fprintf(stderr, "Overflow 1!\n"); + return; + } + *v = *V; v++; V++; + } + y++; + if (y >= h) { return; } + V = v; + v_line_end = &(v[w]); + v_line_next = &(v[w<<2]); + } + if (!(v0 <= v && v < v1)) { return; } + *v = ( ((U&0x80) ? 0xf0 : 0) | ((U&0x40) ? 0x0f : 0) ); + U <<= 2; v++; + if (!(v0 <= v && v < v1)) { return; } + *v = ( ((U&0x80) ? 0xf0 : 0) | ((U&0x40) ? 0x0f : 0) ); + u++; v++; + if (v >= v_line_end) { + while (v < v_line_next) { + if (!(v0 <= v && v < v1)) { + // fprintf(stderr, "Overflow 2!\n"); + return; + } + *v = *V; v++; V++; + } + y++; + if (y >= h) { return; } + V = v; + v_line_end = &(v[w]); + v_line_next = &(v[w<<2]); + } + } +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont3mono_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) +{ + const uint8_t *u = neofont1mono_glyph_bitmap_cb(font, unicode_letter); + static uint8_t v[120 /* = 40 * 24 / 8 */ ]; + mono_bitmap_scale_4(u,v,6,10,u,u+(60+7)/8,v,v+120); + return v; +} + +/*Describe the properties of a font*/ +lv_font_t neofont3mono = { + .get_glyph_dsc = neofont3mono_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont3mono_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 48, /*The real line height where any text fits*/ + .base_line = 8, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool isthin(uint32_t unicode_letter) { + return + unicode_letter == ' ' || + unicode_letter == ':' || + unicode_letter == 'I' || + unicode_letter == 'i' || + unicode_letter == '.'; + // May also add: "'|" +} + +static bool neofont3_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + // if (unicode_letter == '\n') { return false; } + bool thin = isthin(unicode_letter); + dsc_out->adv_w = thin ? 16 : 32; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 40; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 24; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = thin ? (4-8) : 4; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -4; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont3_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { + if ((unicode_letter == 'I') || (unicode_letter == 'i')) { + unicode_letter = '|'; + } + return neofont3mono_glyph_bitmap_cb(font, unicode_letter); +} + +/*Describe the properties of a font*/ +lv_font_t neofont3 = { + .get_glyph_dsc = neofont3_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont3_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 48, /*The real line height where any text fits*/ + .base_line = 8, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +/* Get info about glyph of `unicode_letter` in `font` font. + * Store the result in `dsc_out`. + * The next letter (`unicode_letter_next`) might be used to calculate the width required by this glyph (kerning) + */ +static bool neofont2_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) +{ + // if (unicode_letter == '\n') { return false; } + bool thin = isthin(unicode_letter); + dsc_out->adv_w = thin ? 8 : 16; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 20; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 12; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = thin ? (2-4) : 2; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -2; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont2_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { + if ((unicode_letter == 'I') || (unicode_letter == 'i')) { + unicode_letter = '|'; + } + return neofont2mono_glyph_bitmap_cb(font, unicode_letter); +} + +/*Describe the properties of a font*/ +lv_font_t neofont2 = { + .get_glyph_dsc = neofont2_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont2_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 24, /*The real line height where any text fits*/ + .base_line = 4, /*Base line measured from the top of line_height*/ + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool neofont15_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + // if (unicode_letter == '\n') { return false; } + bool thin = isthin(unicode_letter); + dsc_out->adv_w = thin ? 6 : 12; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 15; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 9; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = thin ? (1-3) : 1; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -1; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont15_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { + if ((unicode_letter == 'I') || (unicode_letter == 'i')) { + unicode_letter = '|'; + } + return neofont15mono_glyph_bitmap_cb(font, unicode_letter); +} + +/*Describe the properties of a font*/ lv_font_t neofont15 = { .get_glyph_dsc = neofont15_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ .get_glyph_bitmap = neofont15_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ @@ -461,4 +1010,80 @@ lv_font_t neofont15 = { .user_data = 0 /*Optionally some extra user data*/ }; +static bool neofont1_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + // if (unicode_letter == '\n') { return false; } + bool thin = isthin(unicode_letter); + dsc_out->adv_w = thin ? 4 : 8; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 10; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 6; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = thin ? (1-2) : 1; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = -1; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* Get the bitmap of `unicode_letter` from `font`. */ +static const uint8_t * neofont1_glyph_bitmap_cb(const lv_font_t * font, uint32_t unicode_letter) { + if ((unicode_letter == 'I') || (unicode_letter == 'i')) { + unicode_letter = '|'; + } + return neofont1mono_glyph_bitmap_cb(font, unicode_letter); +} + +/*Describe the properties of a font*/ +lv_font_t neofont1 = { + .get_glyph_dsc = neofont1_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont1_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 12, /*The real line height where any text fits*/ + .base_line = 2, + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + +static bool neofont0_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) { + // if (unicode_letter == '\n') { return false; } + bool thin = isthin(unicode_letter); + dsc_out->adv_w = thin ? 2 : 4; /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 5; /*Height of the bitmap in [px]*/ + dsc_out->box_w = 3; /*Width of the bitmap in [px]*/ + dsc_out->ofs_x = thin ? (0-1) : 0; /*X offset of the bitmap in [pf]*/ + dsc_out->ofs_y = 0; /*Y offset of the bitmap measured from the as line*/ + dsc_out->bpp = 1; /*Bits per pixel: 1/2/4/8*/ + + return true; /*true: glyph found; false: glyph was not found*/ +} + +/* 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) { + if ((unicode_letter == 'I') || (unicode_letter == 'i')) { + unicode_letter = '|'; + } + return neofont0mono_glyph_bitmap_cb(font, unicode_letter); +} + +/*Describe the properties of a font*/ +lv_font_t neofont0 = { + .get_glyph_dsc = neofont0_glyph_dsc_cb, /*Set a callback to get info about gylphs*/ + .get_glyph_bitmap = neofont0_glyph_bitmap_cb, /*Set a callback to get bitmap of a glyp*/ + .line_height = 12, /*The real line height where any text fits*/ + .base_line = 2, + .dsc = 0, /*Store any implementation specific data here*/ +#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) + .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = 0, + .underline_thickness = 0, +#endif + .user_data = 0 /*Optionally some extra user data*/ +}; + |
