|
@@ -41,16 +41,27 @@ static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t
|
|
|
struct hz_cache *cache, search;
|
|
|
|
|
|
search.hz_id = hz_id;
|
|
|
- cache = SPLAY_FIND(cache_tree, &(font->cache_root), &search);
|
|
|
+
|
|
|
+ /* enter critical */
|
|
|
+ rtgui_enter_critical();
|
|
|
+
|
|
|
+ cache = SPLAY_FIND(cache_tree, &(font->cache_root), &search);
|
|
|
if (cache != RT_NULL)
|
|
|
{
|
|
|
- /* find it */
|
|
|
+ /* exit critical */
|
|
|
+ rtgui_exit_critical();
|
|
|
+
|
|
|
+ /* found it */
|
|
|
return (rt_uint8_t*)(cache + 1);
|
|
|
}
|
|
|
|
|
|
- /* can not find it, load to cache */
|
|
|
+ /* exit critical */
|
|
|
+ rtgui_exit_critical();
|
|
|
+
|
|
|
+ /* can not find it, load to cache */
|
|
|
cache = (struct hz_cache*) rtgui_malloc(sizeof(struct hz_cache) + font->font_data_size);
|
|
|
- if (cache == RT_NULL) return RT_NULL; /* no memory yet */
|
|
|
+ if (cache == RT_NULL)
|
|
|
+ return RT_NULL; /* no memory yet */
|
|
|
|
|
|
cache->hz_id = hz_id;
|
|
|
seek = 94 * (((hz_id & 0xff) - 0xA0) - 1) + ((hz_id >> 8) - 0xA0) - 1;
|
|
@@ -65,7 +76,10 @@ static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t
|
|
|
return RT_NULL;
|
|
|
}
|
|
|
|
|
|
- /* insert to cache */
|
|
|
+ /* enter critical */
|
|
|
+ rtgui_enter_critical();
|
|
|
+
|
|
|
+ /* insert to cache */
|
|
|
SPLAY_INSERT(cache_tree, &(font->cache_root), cache);
|
|
|
font->cache_size ++;
|
|
|
|
|
@@ -78,9 +92,13 @@ static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t
|
|
|
|
|
|
/* remove the left node */
|
|
|
SPLAY_REMOVE(cache_tree, &(font->cache_root), left);
|
|
|
+ rtgui_free(left);
|
|
|
font->cache_size --;
|
|
|
}
|
|
|
|
|
|
+ /* exit critical */
|
|
|
+ rtgui_exit_critical();
|
|
|
+
|
|
|
return (rt_uint8_t*)(cache + 1);
|
|
|
}
|
|
|
|
|
@@ -94,8 +112,14 @@ static void rtgui_hz_file_font_load(struct rtgui_font* font)
|
|
|
|
|
|
static void _rtgui_hz_file_font_draw_text(struct rtgui_hz_file_font* hz_file_font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect)
|
|
|
{
|
|
|
- register rt_base_t h, word_bytes;
|
|
|
rt_uint8_t* str;
|
|
|
+ rtgui_color_t bc;
|
|
|
+ rt_uint16_t style;
|
|
|
+ register rt_base_t h, word_bytes;
|
|
|
+
|
|
|
+ /* get text style */
|
|
|
+ style = rtgui_dc_get_gc(dc)->textstyle;
|
|
|
+ bc = rtgui_dc_get_gc(dc)->background;
|
|
|
|
|
|
/* drawing height */
|
|
|
h = (hz_file_font->font_size + rect->y1 > rect->y2)?
|
|
@@ -123,6 +147,10 @@ static void _rtgui_hz_file_font_draw_text(struct rtgui_hz_file_font* hz_file_fon
|
|
|
{
|
|
|
rtgui_dc_draw_point(dc, rect->x1 + 8*j + k, rect->y1 + i);
|
|
|
}
|
|
|
+ else if (style & RTGUI_TEXTSTYLE_DRAW_BACKGROUND)
|
|
|
+ {
|
|
|
+ rtgui_dc_draw_color_point(dc, rect->x1 + 8*j + k, rect->y1 + i, bc);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|