From d8c3350965860a1a6780bcc46e76af23cc86f733 Mon Sep 17 00:00:00 2001 From: Sun Haiyong Date: Tue, 26 Mar 2024 12:29:18 +0000 Subject: [PATCH 20/22] UniVT: Support displaying UTF-8 text for 180 degree rotation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 支持显示内容进行180度旋转时显示UTF-8文字。 Signed-off-by: Shi Pujin --- drivers/video/fbdev/core/fbcon_ud.c | 60 ++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon_ud.c b/drivers/video/fbdev/core/fbcon_ud.c index 23bc045769d0..fb4ff245f244 100644 --- a/drivers/video/fbdev/core/fbcon_ud.c +++ b/drivers/video/fbdev/core/fbcon_ud.c @@ -18,6 +18,8 @@ #include "fbcon.h" #include "fbcon_rotate.h" +extern u16 utf8_pos(struct vc_data *vc, const unsigned short *utf8); + /* * Rotation 180 degrees */ @@ -92,13 +94,29 @@ static inline void ud_putcs_aligned(struct vc_data *vc, struct fb_info *info, u32 idx = vc->vc_font.width >> 3; u8 *src; + int utf8_c = 0; while (cnt--) { - src = ops->fontbuffer + (scr_readw(s--) & charmask)*cellsize; - + utf8_c = utf8_pos(vc, s); + if(((scr_readw(s) & charmask) == 0xff || (scr_readw(s) & charmask) == 0xfe ) && utf8_c != 0){ + char dst[16]; + utf8_c -= 128; + if((scr_readw(s) & charmask) == 0xff){ + src = vc->vc_font.data + (utf8_c * 32); + }else{ + src = vc->vc_font.data + (utf8_c * 32 + 16); + } + memset(dst, 0, 16); + rotate_ud(src, dst, vc->vc_font.width, + vc->vc_font.height); + src = dst; + }else{ + src = ops->fontbuffer + (scr_readw(s) & charmask)*cellsize; + } if (attr) { ud_update_attr(buf, src, attr, vc); src = buf; } + s--; if (likely(idx == 1)) __fb_pad_aligned_buffer(dst, d_pitch, src, idx, @@ -127,13 +145,29 @@ static inline void ud_putcs_unaligned(struct vc_data *vc, u32 idx = vc->vc_font.width >> 3; u8 *src; + int utf8_c = 0; while (cnt--) { - src = ops->fontbuffer + (scr_readw(s--) & charmask)*cellsize; - + utf8_c = utf8_pos(vc, s); + if(((scr_readw(s) & charmask) == 0xff || (scr_readw(s) & charmask) == 0xfe ) && utf8_c != 0){ + char dst[16]; + utf8_c -= 128; + if((scr_readw(s) & charmask) == 0xff){ + src = vc->vc_font.data + (utf8_c * 32); + }else{ + src = vc->vc_font.data + (utf8_c * 32 + 16); + } + memset(dst, 0, 16); + rotate_ud(src, dst, vc->vc_font.width, + vc->vc_font.height); + src = dst; + }else{ + src = ops->fontbuffer + (scr_readw(s) & charmask)*cellsize; + } if (attr) { ud_update_attr(buf, src, attr, vc); src = buf; } + s--; fb_pad_unaligned_buffer(dst, d_pitch, src, idx, image->height, shift_high, @@ -254,6 +288,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, struct fb_cursor cursor; struct fbcon_ops *ops = info->fbcon_par; unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; + int c_extra; int w = (vc->vc_font.width + 7) >> 3, c; int y = real_y(ops->p, vc->state.y); int attribute, use_sw = vc->vc_cursor_type & CUR_SW; @@ -268,8 +303,23 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, cursor.set = 0; c = scr_readw((u16 *) vc->vc_pos); + c_extra = utf8_pos(vc, (u16 *) vc->vc_pos); attribute = get_attribute(info, c); - src = ops->fontbuffer + ((c & charmask) * (w * vc->vc_font.height)); + if(((c&charmask) == 0xff || (c & charmask) == 0xfe) && c_extra != 0){ + char dst[16]; + c_extra -= 128; + if((c & charmask) == 0xff){ + src = vc->vc_font.data + (c_extra * 32); + }else{ + src = vc->vc_font.data + (c_extra * 32 + 16); + } + memset(dst, 0, 16); + rotate_ud(src, dst, vc->vc_font.width, + vc->vc_font.height); + src = dst; + }else{ + src = ops->fontbuffer + ((c & charmask) * (w * vc->vc_font.height)); + } if (ops->cursor_state.image.data != src || ops->cursor_reset) { -- 2.34.3