From patchwork Wed Jun 22 22:23:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 9193859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A3D7E6075A for ; Wed, 22 Jun 2016 22:24:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DCDB28418 for ; Wed, 22 Jun 2016 22:24:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F88428420; Wed, 22 Jun 2016 22:24:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3032928418 for ; Wed, 22 Jun 2016 22:24:14 +0000 (UTC) Received: from localhost ([::1]:32924 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFqZB-00043o-8v for patchwork-qemu-devel@patchwork.kernel.org; Wed, 22 Jun 2016 18:24:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFqYY-00043U-Ov for qemu-devel@nongnu.org; Wed, 22 Jun 2016 18:23:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFqYT-0006DZ-Nq for qemu-devel@nongnu.org; Wed, 22 Jun 2016 18:23:33 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:39486) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFqYT-0006DP-BT for qemu-devel@nongnu.org; Wed, 22 Jun 2016 18:23:29 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 4BE138AB9; Thu, 23 Jun 2016 00:23:23 +0200 (CEST) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1CPEqBGI44Cb; Thu, 23 Jun 2016 00:23:23 +0200 (CEST) Received: from var.youpi.perso.aquilenet.fr (ARennes-656-1-291-142.w2-10.abo.wanadoo.fr [2.10.55.142]) by hera.aquilenet.fr (Postfix) with ESMTPSA id A65588AB8; Thu, 23 Jun 2016 00:23:22 +0200 (CEST) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.87) (envelope-from ) id 1bFqYP-0006Pu-1Z; Thu, 23 Jun 2016 00:23:25 +0200 From: Samuel Thibault To: qemu-devel@nongnu.org, kraxel@redhat.com, pbonzini@redhat.com, berrange@redhat.com, peter.maydell@linaro.org, mjt@tls.msk.ru Date: Thu, 23 Jun 2016 00:23:21 +0200 Message-Id: <1466634202-24616-5-git-send-email-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1466634202-24616-1-git-send-email-samuel.thibault@ens-lyon.org> References: <1466634202-24616-1-git-send-email-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:474::1 Subject: [Qemu-devel] [PATCH 4/5] curses: add option to specify VGA font encoding X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This detects and uses iconv to convert glyphs from the specified VGA font encoding to unicode. Signed-off-by: Samuel Thibault --- configure | 37 +++++++++++++++++++++++++++++++++++++ include/sysemu/sysemu.h | 1 + qemu-options.hx | 20 ++++++++++++++++++++ ui/curses.c | 40 ++++++++++++++++++++++++++++++++++++++++ vl.c | 4 ++++ 5 files changed, 102 insertions(+) diff --git a/configure b/configure index ff10012..14e98f5 100755 --- a/configure +++ b/configure @@ -204,6 +204,7 @@ brlapi="" curl="" curses="" cursesw="" +iconv="" docs="" fdt="" netmap="no" @@ -983,6 +984,10 @@ for opt do ;; --enable-cursesw) cursesw="yes" ;; + --disable-iconv) iconv="no" + ;; + --enable-iconv) iconv="yes" + ;; --disable-curl) curl="no" ;; --enable-curl) curl="yes" @@ -1333,6 +1338,7 @@ disabled with --disable-FEATURE, default is enabled if available: vte vte support for the gtk UI curses curses UI cursesw cursesw UI + iconv font glyph conversion support vnc VNC UI support vnc-sasl SASL encryption for VNC server vnc-jpeg JPEG lossy compression for VNC server @@ -2968,6 +2974,33 @@ EOF fi ########################################## +# iconv probe +if test "$iconv" != "no" ; then + cat > $TMPC << EOF +#include +int main(void) { + iconv_t conv = iconv_open("ISO-8859-1", "ISO-8859-1"); + return conv != (iconv_t) -1; +} +EOF + for iconv_lib in '' -liconv; do + if compile_prog "" "$iconv_lib" ; then + iconv_found=yes + libs_softmmu="$iconv_lib $libs_softmmu" + break + fi + done + if test "$iconv_found" = "yes" ; then + iconv=yes + else + if test "$iconv" = "yes" ; then + feature_not_found "iconv" "Install iconv devel" + fi + iconv=no + fi +fi + +########################################## # curl probe if test "$curl" != "no" ; then if $pkg_config libcurl --exists; then @@ -4859,6 +4892,7 @@ echo "nettle kdf $nettle_kdf" echo "libtasn1 $tasn1" echo "curses support $curses" echo "cursesw support $cursesw" +echo "iconv support $iconv" echo "virgl support $virglrenderer" echo "curl support $curl" echo "mingw32 support $mingw32" @@ -5120,6 +5154,9 @@ fi if test "$cursesw" = "yes" ; then echo "CONFIG_CURSESW=y" >> $config_host_mak fi +if test "$iconv" = "yes" ; then + echo "CONFIG_ICONV=y" >> $config_host_mak +fi if test "$utimens" = "yes" ; then echo "CONFIG_UTIMENSAT=y" >> $config_host_mak fi diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 7313673..a690c18 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -147,6 +147,7 @@ extern int graphic_height; extern int graphic_depth; extern int display_opengl; extern const char *keyboard_layout; +extern const char *font_encoding; extern int win2k_install_hack; extern int alt_grab; extern int ctrl_grab; diff --git a/qemu-options.hx b/qemu-options.hx index ce535a9..2187886 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -321,6 +321,26 @@ The default is @code{en-us}. ETEXI +DEF("f", HAS_ARG, QEMU_OPTION_f, + "-f encoding use font encoding (for example 'CP850' for IBM CP850 encoding)\n", + QEMU_ARCH_ALL) +STEXI +@item -h @var{encoding} +@findex -h +Use font encoding @var{encoding} (for example @code{CP850} for +IBM CP/850 encoding). This option is only needed where output is text-only, i.e. +with the curses display, to convert from text-mode output from the guest to +proper text glyphs. + +The available encoding are provided by the libc, the full list can be obtained by +@example +iconv -l +@end example + +The default is @code{CP437}. +ETEXI + + DEF("audio-help", 0, QEMU_OPTION_audio_help, "-audio-help print list of audio drivers and their options\n", QEMU_ARCH_ALL) diff --git a/ui/curses.c b/ui/curses.c index 9ef54b5..a8dada9 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -33,6 +33,9 @@ #include #include #endif +#ifdef CONFIG_ICONV +#include +#endif #include "qemu-common.h" #include "ui/console.h" @@ -412,6 +415,43 @@ static void curses_setup(void) vga_to_curses[0x1e].chars[0] = L'\u25b2'; vga_to_curses[0x1f].chars[0] = L'\u25bc'; +#ifdef CONFIG_ICONV + if (font_encoding) { + unsigned char ch; + wchar_t wch; + char *pch, *pwch; + size_t sch, swch; + iconv_t conv; + + conv = iconv_open("WCHAR_T", font_encoding); + if (conv == (iconv_t) -1) { + fprintf(stderr, "Could not convert font glyphs from %s: '%s'\n", font_encoding, strerror(errno)); + exit(1); + } + + for (i = 0x20; i <= 0xff; i++) + { + ch = i; + pch = (char*) &ch; + pwch = (char*) &wch; + sch = sizeof(ch); + swch = sizeof(wch); + if (iconv(conv, &pch, &sch, &pwch, &swch) == (size_t) -1) { + fprintf(stderr,"Could not convert 0x%2x from %s: '%s'\n", ch, font_encoding, strerror(errno)); + } else { + vga_to_curses[ch].chars[0] = wch; + } + } + } else +#else + if (font_encoding) { + if (strcmp(font_encoding, "CP437")) + { + fprintf(stderr,"iconv support not enabled for converting from %s, only CP437 supported\n", font_encoding); + exit(1); + } + } +#endif { /* Hardcode CP437 to unicode */ vga_to_curses[0x80].chars[0] = L'\u00C7'; diff --git a/vl.c b/vl.c index 2f63eb4..508a59f 100644 --- a/vl.c +++ b/vl.c @@ -132,6 +132,7 @@ enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; int request_opengl = -1; int display_opengl; const char* keyboard_layout = NULL; +const char* font_encoding = NULL; ram_addr_t ram_size; const char *mem_path = NULL; int mem_prealloc = 0; /* force preallocation of physical target memory */ @@ -3370,6 +3371,9 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_k: keyboard_layout = optarg; break; + case QEMU_OPTION_f: + font_encoding = optarg; + break; case QEMU_OPTION_localtime: rtc_utc = 0; break;