From d78a37676efbc24ce1d5c46b65c6caf45ff3bc27 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 23 Oct 2020 00:40:52 -0400 Subject: ClipPlus BOOTLOADER DONT FIT! REMOVED FROM ALL NATIVE BOOTLOADERS: finish removing the text scrolling pare down printf to a minimal subset (%c %s %l %d %u and %x(%p)) remove diacritic and rtl language support GOAL 134000 START 135305 CURRENT 133700 SUCCESS! (ASSUMING IT WORKS -- UNESTED) Change-Id: Ic3f6ac1dc260578f581ee53458b3e5bb47d313ec --- firmware/drivers/lcd-bitmap-common.c | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'firmware/drivers/lcd-bitmap-common.c') diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 22430d4e50..8c38e513c6 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c @@ -118,6 +118,7 @@ void LCDFN(update_viewport_rect)(int x, int y, int width, int height) LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height); } +#ifndef BOOTLOADER /* put a string at a given pixel position, skipping first ofs pixel columns */ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) { @@ -257,6 +258,72 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) } font_lock(current_vp->font, false); } +#else /* BOOTLOADER */ +/* put a string at a given pixel position, skipping first ofs pixel columns */ +static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) +{ + unsigned short *ucs; + struct font* pf = font_get(current_vp->font); + int vp_flags = current_vp->flags; + const unsigned char *bits; + int width; + + if ((vp_flags & VP_FLAG_ALIGNMENT_MASK) != 0) + { + int w; + + LCDFN(getstringsize)(str, &w, NULL); + /* center takes precedence */ + if (vp_flags & VP_FLAG_ALIGN_CENTER) + { + x = ((current_vp->width - w)/ 2) + x; + if (x < 0) + x = 0; + } + else + { + x = current_vp->width - w - x; + x += ofs; + ofs = 0; + } + } + + /* allow utf but no diacritics or rtl lang */ + for (ucs = bidi_l2v(str, 1); *ucs; ucs++) + { + const unsigned short next_ch = ucs[1]; + + if (x >= current_vp->width) + break; + + /* Get proportional width and glyph bits */ + width = font_get_width(pf, *ucs); + + if (ofs > width) + { + ofs -= width; + continue; + } + + bits = font_get_bits(pf, *ucs); + +#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) + if (pf->depth) + lcd_alpha_bitmap_part(bits, ofs, 0, width, x, y, + width - ofs, pf->height); + else +#endif + LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x, + y, width - ofs, pf->height); + if (next_ch) + { + x += width - ofs; + ofs = 0; + } + } +} +#endif + /*** pixel oriented text output ***/ -- cgit v1.2.3