Index: firmware/export/font.h =================================================================== --- firmware/export/font.h (revision 30753) +++ firmware/export/font.h (working copy) @@ -118,6 +118,7 @@ const char* font_filename(int font_id); int font_load(const char *path); int font_load_ex(const char *path, size_t buffer_size); +void font_lock( int font_id, bool lock); int font_glyphs_to_bufsize(const char *path, int glyphs); void font_unload(int font_id); Index: firmware/font.c =================================================================== --- firmware/font.c (revision 30753) +++ firmware/font.c (working copy) @@ -117,6 +117,14 @@ alloc->handle_locks--; } +void font_lock(int font_id, bool lock) +{ + if( font_id == FONT_SYSFIXED ) + return; + if( buflib_allocations[font_id] != -1 ) + lock_font_handle(buflib_allocations[font_id], lock); +} + static struct buflib_callbacks buflibops = {buflibmove_callback, NULL }; static inline struct font *pf_from_handle(int handle) @@ -919,7 +927,8 @@ struct font* pf = font_get(fontnumber); unsigned short ch; int width = 0; - + + font_lock( fontnumber, true ); for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch)) { if (is_diacritic(ch, NULL)) @@ -932,6 +941,7 @@ *w = width; if ( h ) *h = pf->height; + font_lock( fontnumber, false ); return width; } Index: firmware/drivers/lcd-bitmap-common.c =================================================================== --- firmware/drivers/lcd-bitmap-common.c (revision 30753) +++ firmware/drivers/lcd-bitmap-common.c (working copy) @@ -101,6 +101,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) { unsigned short *ucs; + font_lock(current_vp->font, true); struct font* pf = font_get(current_vp->font); int vp_flags = current_vp->flags; int rtl_next_non_diac_width, last_non_diacritic_width; @@ -233,6 +234,7 @@ } } } + font_lock(current_vp->font, false); } /* put a string at a given pixel position */ @@ -457,6 +459,7 @@ else s->offset += LCDFN(scroll_info).step; + font_lock(current_vp->font, true); pf = font_get(current_vp->font); xpos = s->startx; ypos = s->y * pf->height + s->y_offset; @@ -492,6 +495,7 @@ pf->height, s->offset); LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width - xpos, pf->height); + font_lock(current_vp->font, false); } LCDFN(set_viewport)(old_vp); }