summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-bitmap-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-bitmap-common.c')
-rw-r--r--firmware/drivers/lcd-bitmap-common.c67
1 files changed, 67 insertions, 0 deletions
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)
118 LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height); 118 LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height);
119} 119}
120 120
121#ifndef BOOTLOADER
121/* put a string at a given pixel position, skipping first ofs pixel columns */ 122/* put a string at a given pixel position, skipping first ofs pixel columns */
122static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) 123static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
123{ 124{
@@ -257,6 +258,72 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
257 } 258 }
258 font_lock(current_vp->font, false); 259 font_lock(current_vp->font, false);
259} 260}
261#else /* BOOTLOADER */
262/* put a string at a given pixel position, skipping first ofs pixel columns */
263static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
264{
265 unsigned short *ucs;
266 struct font* pf = font_get(current_vp->font);
267 int vp_flags = current_vp->flags;
268 const unsigned char *bits;
269 int width;
270
271 if ((vp_flags & VP_FLAG_ALIGNMENT_MASK) != 0)
272 {
273 int w;
274
275 LCDFN(getstringsize)(str, &w, NULL);
276 /* center takes precedence */
277 if (vp_flags & VP_FLAG_ALIGN_CENTER)
278 {
279 x = ((current_vp->width - w)/ 2) + x;
280 if (x < 0)
281 x = 0;
282 }
283 else
284 {
285 x = current_vp->width - w - x;
286 x += ofs;
287 ofs = 0;
288 }
289 }
290
291 /* allow utf but no diacritics or rtl lang */
292 for (ucs = bidi_l2v(str, 1); *ucs; ucs++)
293 {
294 const unsigned short next_ch = ucs[1];
295
296 if (x >= current_vp->width)
297 break;
298
299 /* Get proportional width and glyph bits */
300 width = font_get_width(pf, *ucs);
301
302 if (ofs > width)
303 {
304 ofs -= width;
305 continue;
306 }
307
308 bits = font_get_bits(pf, *ucs);
309
310#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR)
311 if (pf->depth)
312 lcd_alpha_bitmap_part(bits, ofs, 0, width, x, y,
313 width - ofs, pf->height);
314 else
315#endif
316 LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x,
317 y, width - ofs, pf->height);
318 if (next_ch)
319 {
320 x += width - ofs;
321 ofs = 0;
322 }
323 }
324}
325#endif
326
260 327
261/*** pixel oriented text output ***/ 328/*** pixel oriented text output ***/
262 329