diff options
Diffstat (limited to 'src/displayapp/fonts/neofont.c')
| -rw-r--r-- | src/displayapp/fonts/neofont.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/src/displayapp/fonts/neofont.c b/src/displayapp/fonts/neofont.c index c868c99..00c1e8f 100644 --- a/src/displayapp/fonts/neofont.c +++ b/src/displayapp/fonts/neofont.c @@ -554,6 +554,137 @@ lv_font_t neofont1 = { .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) +{ + /*Your code here*/ + + /* Store the result. + * For example ... + */ + + // ######..###### + // ##::::..::##:: + // ######..::##:: + // ::::##..::##:: + // ######..::##:: + + // ######..######.. + // ######..######.. + // ##::::..::##::.. + // ##::::..::##::.. + // ######..::##::.. + // ######..::##::.. + // ::::##..::##::.. + // ::::##..::##::.. + // ######..::##::.. + // ######..::##::.. + + 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->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) +{ + const uint8_t *u = neofont0_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; + 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,a,b,b,b,c,c); + v[1] = P(c, + a,a,a,b,b,b,c); + v[2] = P(c,c, + a,a,a,b,b,b); + v[3] = P(c,c,c, + + d,d,d,e,e); + v[4] = P(e,f,f,f, + d,d,d,e); + v[5] = P(e,e,f,f,f, + d,d,d); + v[6] = P(e,e,e,f,f,f, + + g,g); + v[7] = P(g,h,h,h,i,i,i, + g); + v[8] = P(g,g,h,h,h,i,i,i); + v[9] = P(g,g,g,h,h,h,i,i); + v[10] = P(i, + + j,j,j,k,k,k,l); + v[11] = P(l,l, + j,j,j,k,k,k); + v[12] = P(l,l,l, + j,j,j,k,k); + v[13] = P(k,l,l,l, + + m,m,m,n); + v[14] = P(n,n,o,o,o, + m,m,m); + v[15] = P(n,n,n,o,o,o, + m,m); + v[16] = P(m,n,n,n,o,o,o,0); + +#undef P + + return v; /*Or NULL if not found*/ +} + +/*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*/ + .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) |
