From owner-svn-src-all@FreeBSD.ORG Fri Dec 20 21:31:53 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D95F2199; Fri, 20 Dec 2013 21:31:52 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C4DD21D48; Fri, 20 Dec 2013 21:31:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBKLVqms054866; Fri, 20 Dec 2013 21:31:52 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBKLVpsA054857; Fri, 20 Dec 2013 21:31:51 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201312202131.rBKLVpsA054857@svn.freebsd.org> From: Ed Schouten Date: Fri, 20 Dec 2013 21:31:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259667 - in head/sys: dev/syscons dev/vt kern sys teken teken/demo X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Dec 2013 21:31:53 -0000 Author: ed Date: Fri Dec 20 21:31:50 2013 New Revision: 259667 URL: http://svnweb.freebsd.org/changeset/base/259667 Log: Extend libteken to support CJK fullwidth characters. Introduce a new formatting bit (TF_CJK_RIGHT) that is set when putting a cell that is the right part of a CJK fullwidth character. This will allow drivers like vt(9) to support fullwidth characters properly. emaste@ has a patch to extend vt(9)'s font handling to increase the number of Unicode -> glyph maps from 2 ({normal,bold)} to 4 ({normal,bold} x {left,right}). This will need to use this formatting bit to determine whether to draw the left or right glyph. Reviewed by: emaste Modified: head/sys/dev/syscons/scterm-teken.c head/sys/dev/vt/vt_font.c head/sys/kern/subr_terminal.c head/sys/sys/terminal.h head/sys/teken/demo/teken_demo.c head/sys/teken/teken.h head/sys/teken/teken_subr.h Modified: head/sys/dev/syscons/scterm-teken.c ============================================================================== --- head/sys/dev/syscons/scterm-teken.c Fri Dec 20 20:57:13 2013 (r259666) +++ head/sys/dev/syscons/scterm-teken.c Fri Dec 20 21:31:50 2013 (r259667) @@ -553,7 +553,14 @@ scteken_putchar(void *arg, const teken_p vm_offset_t p; int cursor, attr; + /* + * No support for printing right hand sides for CJK fullwidth + * characters. Simply print a space and assume that the left + * hand side describes the entire character. + */ attr = scteken_attr(a) << 8; + if (a->ta_format & TF_CJK_RIGHT) + c = ' '; #ifdef TEKEN_UTF8 scteken_get_cp437(&c, &attr); #endif /* TEKEN_UTF8 */ Modified: head/sys/dev/vt/vt_font.c ============================================================================== --- head/sys/dev/vt/vt_font.c Fri Dec 20 20:57:13 2013 (r259666) +++ head/sys/dev/vt/vt_font.c Fri Dec 20 21:31:50 2013 (r259667) @@ -87,7 +87,15 @@ vtfont_lookup(const struct vt_font *vf, uint16_t dst; size_t stride; + /* + * No support for printing right hand sides for CJK fullwidth + * characters. Simply print a space and assume that the left + * hand side describes the entire character. + */ src = TCHAR_CHARACTER(c); + if (TCHAR_FORMAT(c) & TF_CJK_RIGHT) + src = ' '; + if (TCHAR_FORMAT(c) & TF_BOLD) { dst = vtfont_bisearch(vf->vf_bold, vf->vf_bold_length, src); if (dst != 0) Modified: head/sys/kern/subr_terminal.c ============================================================================== --- head/sys/kern/subr_terminal.c Fri Dec 20 20:57:13 2013 (r259666) +++ head/sys/kern/subr_terminal.c Fri Dec 20 21:31:50 2013 (r259667) @@ -128,7 +128,7 @@ static const teken_attr_t default_messag }; #define TCHAR_CREATE(c, a) ((c) | \ - (a)->ta_format << 22 | \ + (a)->ta_format << 21 | \ teken_256to8((a)->ta_fgcolor) << 26 | \ teken_256to8((a)->ta_bgcolor) << 29) Modified: head/sys/sys/terminal.h ============================================================================== --- head/sys/sys/terminal.h Fri Dec 20 20:57:13 2013 (r259666) +++ head/sys/sys/terminal.h Fri Dec 20 21:31:50 2013 (r259667) @@ -62,15 +62,14 @@ struct tty; * * Bits Meaning * 0-20: Character value - * 21: Unused - * 22-25: Bold, underline, blink, reverse + * 21-25: Bold, underline, blink, reverse, right part of CJK fullwidth character * 26-28: Foreground color * 29-31: Background color */ typedef uint32_t term_char_t; #define TCHAR_CHARACTER(c) ((c) & 0x1fffff) -#define TCHAR_FORMAT(c) (((c) >> 22) & 0xf) +#define TCHAR_FORMAT(c) (((c) >> 21) & 0x1f) #define TCHAR_FGCOLOR(c) (((c) >> 26) & 0x7) #define TCHAR_BGCOLOR(c) ((c) >> 29) Modified: head/sys/teken/demo/teken_demo.c ============================================================================== --- head/sys/teken/demo/teken_demo.c Fri Dec 20 20:57:13 2013 (r259666) +++ head/sys/teken/demo/teken_demo.c Fri Dec 20 21:31:50 2013 (r259667) @@ -86,9 +86,10 @@ printchar(const teken_pos_t *p) assert(p->tp_row < NROWS); assert(p->tp_col < NCOLS); - getyx(stdscr, y, x); - px = &buffer[p->tp_col][p->tp_row]; + /* No need to print right hand side of CJK character manually. */ + if (px->a.ta_format & TF_CJK_RIGHT) + return; /* Convert Unicode to UTF-8. */ if (px->c < 0x80) { @@ -118,8 +119,8 @@ printchar(const teken_pos_t *p) bkgdset(attr | COLOR_PAIR(teken_256to8(px->a.ta_fgcolor) + 8 * teken_256to8(px->a.ta_bgcolor))); + getyx(stdscr, y, x); mvaddstr(p->tp_row, p->tp_col, str); - move(y, x); } Modified: head/sys/teken/teken.h ============================================================================== --- head/sys/teken/teken.h Fri Dec 20 20:57:13 2013 (r259666) +++ head/sys/teken/teken.h Fri Dec 20 21:31:50 2013 (r259667) @@ -41,10 +41,11 @@ typedef uint32_t teken_char_t; typedef unsigned short teken_unit_t; typedef unsigned char teken_format_t; -#define TF_BOLD 0x01 -#define TF_UNDERLINE 0x02 -#define TF_BLINK 0x04 -#define TF_REVERSE 0x08 +#define TF_BOLD 0x01 /* Bold character. */ +#define TF_UNDERLINE 0x02 /* Underline character. */ +#define TF_BLINK 0x04 /* Blinking character. */ +#define TF_REVERSE 0x08 /* Reverse rendered character. */ +#define TF_CJK_RIGHT 0x10 /* Right-hand side of CJK character. */ typedef unsigned char teken_color_t; #define TC_BLACK 0 #define TC_RED 1 Modified: head/sys/teken/teken_subr.h ============================================================================== --- head/sys/teken/teken_subr.h Fri Dec 20 20:57:13 2013 (r259666) +++ head/sys/teken/teken_subr.h Fri Dec 20 21:31:50 2013 (r259667) @@ -791,21 +791,19 @@ teken_subr_do_putchar(teken_t *t, const teken_funcs_copy(t, &ctr, &ctp); } + teken_funcs_putchar(t, tp, c, &t->t_curattr); + if (width == 2 && tp->tp_col + 1 < t->t_winsize.tp_col) { teken_pos_t tp2; + teken_attr_t attr; - /* - * Store a space behind double width characters before - * actually printing them. This prevents artifacts when - * the consumer doesn't render it using double width - * glyphs. - */ + /* Print second half of CJK fullwidth character. */ tp2.tp_row = tp->tp_row; tp2.tp_col = tp->tp_col + 1; - teken_funcs_putchar(t, &tp2, BLANK, &t->t_curattr); + attr = t->t_curattr; + attr.ta_format |= TF_CJK_RIGHT; + teken_funcs_putchar(t, &tp2, c, &attr); } - - teken_funcs_putchar(t, tp, c, &t->t_curattr); } static void