From 2d98c0e7be8e0803de4b4e8e9ba03635bcef91c8 Mon Sep 17 00:00:00 2001 From: yangfasheng Date: Tue, 12 Dec 2017 19:46:38 +0800 Subject: gui 引擎代码更新; MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/gui/src/font_fnt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'components/gui/src/font_fnt.c') diff --git a/components/gui/src/font_fnt.c b/components/gui/src/font_fnt.c index 28ae24d530..0a0a061206 100644 --- a/components/gui/src/font_fnt.c +++ b/components/gui/src/font_fnt.c @@ -44,10 +44,14 @@ void rtgui_fnt_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, cons rt_uint32_t position; struct fnt_font *fnt; rt_uint8_t *data_ptr; + struct rtgui_rect text_rect; fnt = (struct fnt_font*)font->data; RT_ASSERT(fnt != RT_NULL); + rtgui_font_get_metrics(rtgui_dc_get_gc(dc)->font, text, &text_rect); + rtgui_rect_move_to_align(rect, &text_rect, RTGUI_DC_TEXTALIGN(dc)); + while (len) { /* get character */ @@ -81,16 +85,16 @@ void rtgui_fnt_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, cons for (c = 0; c < (fnt->header.height + 7)/8; c ++) { /* check drawable region */ - if ((rect->x1 + i > rect->x2) || (rect->y1 + c * 8 + j > rect->y2)) + if ((text_rect.x1 + i > text_rect.x2) || (text_rect.y1 + c * 8 + j > text_rect.y2)) continue; if (data_ptr[i + c * width] & (1 << j)) - rtgui_dc_draw_point(dc, rect->x1 + i, rect->y1 + c * 8 + j); + rtgui_dc_draw_point(dc, text_rect.x1 + i, text_rect.y1 + c * 8 + j); } } } - rect->x1 += width; + text_rect.x1 += width; text += 1; len -= 1; } -- cgit v1.3.1