Skip to content

Instantly share code, notes, and snippets.

Created March 18, 2014 05:07
Show Gist options
  • Save anonymous/9613893 to your computer and use it in GitHub Desktop.
Save anonymous/9613893 to your computer and use it in GitHub Desktop.
--- a/drivers/video/console/cfbcondecor.c 2014-03-18 11:45:33.570979410 +0800
+++ b/drivers/video/console/cfbcondecor.c 2014-03-18 11:19:49.593472261 +0800
@@ -25,6 +25,26 @@
#include "fbcon.h"
#include "fbcondecor.h"
+static const unsigned char fontdata_16x16[] = {
+ #include <../lib/fonts/font_cjk.h>
+};
+extern int fbcon_softback_size;
+extern int fbcon_is_softback(const unsigned short *str);
+static inline u16 utf8_pos(struct vc_data *vc, const unsigned short *utf8)
+{
+ unsigned long p = (long)utf8;
+ if (p >= vc->vc_origin && p < vc->vc_scr_end) {
+ return scr_readw((unsigned short *)(p + vc->vc_screenbuf_size));
+ } else if (vc->vc_num == fg_console && fbcon_is_softback(utf8)){
+ return scr_readw((unsigned short *)(p + fbcon_softback_size));
+ } else {
+ u16 extra_c;
+ int c = *(int*)utf8;
+ extra_c = (c >> 16 ) & 0x0000ffff;
+ return extra_c;
+ }
+}
+
#define parse_pixel(shift,bpp,type) \
do { \
if (d & (0x80 >> (shift))) \
@@ -172,7 +192,12 @@
{
unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
struct fbcon_ops *ops = info->fbcon_par;
+ const void *olddata = vc->vc_font.data;
+ int oldwidth = vc->vc_font.width;
+ int oldheight = vc->vc_font.height;
int fg_color, bg_color, transparent;
+ int utf_8 = 0;
+ int utf8_c = 0;
u8 *src;
u32 bgx, fgx;
u16 c = scr_readw(s);
@@ -191,13 +216,33 @@
bgx = cc2cx(bg_color);
while (count--) {
- c = scr_readw(s++);
- src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
- ((vc->vc_font.width + 7) >> 3);
+ utf_8 = 0;
+ c = scr_readw(s);
+ utf8_c = utf8_pos(vc, s);
+ if (((c & charmask) == 0xff || (c & charmask) == 0xfe) && utf8_c != 0){
+ vc->vc_font.data = fontdata_16x16;
+ vc->vc_font.width = 8;
+ vc->vc_font.height = 16;
+ if((c & charmask) == 0xff){
+ src = vc->vc_font.data + (utf8_c * 32);
+ }else{
+ src = vc->vc_font.data + (utf8_c * 32 + 16);
+ }
+ utf_8 = 1;
+ }else{
+ src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
+ ((vc->vc_font.width + 7) >> 3);
+ }
fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
vc->vc_font.width, src, fgx, bgx, transparent);
xx += vc->vc_font.width;
+ if (utf_8 == 1){
+ vc->vc_font.data = (void *)olddata;
+ vc->vc_font.width = oldwidth;
+ vc->vc_font.height = oldheight;
+ }
+ s++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment