diff options
Diffstat (limited to 'src/displayapp/fonts/neofont.c')
| -rw-r--r-- | src/displayapp/fonts/neofont.c | 210 |
1 files changed, 106 insertions, 104 deletions
diff --git a/src/displayapp/fonts/neofont.c b/src/displayapp/fonts/neofont.c index e53f011..1c115e1 100644 --- a/src/displayapp/fonts/neofont.c +++ b/src/displayapp/fonts/neofont.c @@ -730,21 +730,17 @@ static const uint8_t glyphs[96][2] = { * 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 = (unicode_letter >= 32 ? 4 : 0); /*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*/ +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) { + if (unicode_letter < 32) { + return false; + } + dsc_out->adv_w = 4; + dsc_out->box_h = 5; + dsc_out->box_w = 3; + dsc_out->ofs_x = 0; + dsc_out->ofs_y = 0; + dsc_out->bpp = 1; + return true; } /* Get the bitmap of `unicode_letter` from `font`. */ @@ -793,14 +789,6 @@ lv_font_t neofont0mono = { .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 ... - */ - // ######..###### // ##::::..::##:: // ######..::##:: @@ -818,14 +806,17 @@ static bool neofont1mono_glyph_dsc_cb(const lv_font_t * font, lv_font_glyph_dsc_ // ######..::##::.. // ######..::##::.. - dsc_out->adv_w = (unicode_letter >= 32 ? 8 : 0); /*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*/ +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) { + if (unicode_letter < 32) { + return false; + } + dsc_out->adv_w = 8; + dsc_out->box_h = 10; + dsc_out->box_w = 6; + dsc_out->ofs_x = 1; + dsc_out->ofs_y = -1; + dsc_out->bpp = 1; + return true; } #if 0 @@ -973,16 +964,17 @@ lv_font_t neofont1mono = { .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 = (unicode_letter >= 32 ? 12 : 0); /*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 = -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*/ +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) { + if (unicode_letter < 32) { + return false; + } + dsc_out->adv_w = 12; + dsc_out->box_h = 15; + dsc_out->box_w = 9; + dsc_out->ofs_x = 1; + dsc_out->ofs_y = -1; + dsc_out->bpp = 1; + return true; } /* Get the bitmap of `unicode_letter` from `font`. */ @@ -1085,15 +1077,17 @@ lv_font_t neofont15mono = { * 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 = (unicode_letter >= 32 ? 16 : 0); /*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*/ +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) { + if (unicode_letter < 32) { + return false; + } + dsc_out->adv_w = 16; + dsc_out->box_h = 20; + dsc_out->box_w = 12; + dsc_out->ofs_x = 2; + dsc_out->ofs_y = -2; + dsc_out->bpp = 1; + return true; } /* Get the bitmap of `unicode_letter` from `font`. */ @@ -1185,15 +1179,17 @@ lv_font_t neofont2mono = { * 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 = (unicode_letter >= 32 ? 32 : 0); /*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 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) { + if (unicode_letter < 32) { + return false; + } + dsc_out->adv_w = 32; + dsc_out->box_h = 40; + dsc_out->box_w = 24; + dsc_out->ofs_x = 4; + dsc_out->ofs_y = -4; + dsc_out->bpp = 1; + return true; } static void mono_bitmap_scale_4( @@ -1293,15 +1289,17 @@ static bool isthin(uint32_t unicode_letter) { } 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; } + if (unicode_letter < 32) { + return false; + } bool thin = isthin(unicode_letter); - dsc_out->adv_w = unicode_letter < 32 ? 0 : thin ? 16 : (unicode_letter >= 0xF8000 ? 24 : 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*/ + dsc_out->adv_w = thin ? 16 : (unicode_letter >= 0xF8000 ? 24 : 32); + dsc_out->box_h = 40; + dsc_out->box_w = 24; + dsc_out->ofs_x = thin ? (4-8) : 4; + dsc_out->ofs_y = -4; + dsc_out->bpp = 1; + return true; } /* Get the bitmap of `unicode_letter` from `font`. */ @@ -1335,17 +1333,18 @@ lv_font_t neofont3 = { * 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; } +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 < 32) { + return false; + } bool thin = isthin(unicode_letter); - dsc_out->adv_w = unicode_letter < 32 ? 0 : thin ? 8 : (unicode_letter >= 0xF8000 ? 12 : 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*/ + dsc_out->adv_w = thin ? 8 : (unicode_letter >= 0xF8000 ? 12 : 16); + dsc_out->box_h = 20; + dsc_out->box_w = 12; + dsc_out->ofs_x = thin ? (2-4) : 2; + dsc_out->ofs_y = -2; + dsc_out->bpp = 1; + return true; } /* Get the bitmap of `unicode_letter` from `font`. */ @@ -1376,16 +1375,17 @@ lv_font_t neofont2 = { }; 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; } + if (unicode_letter < 32) { + return false; + } bool thin = isthin(unicode_letter); - dsc_out->adv_w = unicode_letter < 32 ? 0 : thin ? 6 : (unicode_letter >= 0xF8000 ? 9 : 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*/ + dsc_out->adv_w = thin ? 6 : (unicode_letter >= 0xF8000 ? 9 : 12); /*Horizontal space required by the glyph in [px]*/ + dsc_out->box_h = 15; + dsc_out->box_w = 9; + dsc_out->ofs_x = thin ? (1-3) : 1; + dsc_out->ofs_y = -1; + dsc_out->bpp = 1; + return true; } /* Get the bitmap of `unicode_letter` from `font`. */ @@ -1416,16 +1416,17 @@ lv_font_t neofont15 = { }; 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; } + if (unicode_letter < 32) { + return false; + } bool thin = isthin(unicode_letter); - dsc_out->adv_w = unicode_letter < 32 ? 0 : thin ? 4 : (unicode_letter >= 0xF8000 ? 6 : 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*/ + dsc_out->adv_w = thin ? 4 : (unicode_letter >= 0xF8000 ? 6 : 8); + dsc_out->box_h = 10; + dsc_out->box_w = 6; + dsc_out->ofs_x = thin ? (1-2) : 1; + dsc_out->ofs_y = -1; + dsc_out->bpp = 1; + return true; } /* Get the bitmap of `unicode_letter` from `font`. */ @@ -1456,16 +1457,17 @@ lv_font_t neofont1 = { }; 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; } + if (unicode_letter < 32) { + return false; + } bool thin = isthin(unicode_letter); - dsc_out->adv_w = unicode_letter < 32 ? 0 : thin ? 2 : (unicode_letter >= 0xF8000 ? 3 : 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*/ + dsc_out->adv_w = thin ? 2 : (unicode_letter >= 0xF8000 ? 3 : 4); + dsc_out->box_h = 5; + dsc_out->box_w = 3; + dsc_out->ofs_x = thin ? (0-1) : 0; + dsc_out->ofs_y = 0; + dsc_out->bpp = 1; + return true; } /* Get the bitmap of `unicode_letter` from `font`. */ |
