GNU bug report logs - #12693
[cygwin] Setting fonts with non-ascii names throws error

Previous Next

Package: emacs;

Reported by: Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>

Date: Sat, 20 Oct 2012 21:49:01 UTC

Severity: normal

Found in version 24.2.50

Full log


View this message in rfc822 format

From: Kazuhiro Ito <kzhr <at> d1.dion.ne.jp>
To: 12693 <at> debbugs.gnu.org
Subject: bug#12693: 24.2.50; src/w32font.c should depend on ANSI code page
Date: Sun, 21 Oct 2012 06:46:04 +0900
When I run Emacs on Cygwin with the native Windows UI, I can't specify
font by non-ascii font name.  For example, the below code success on
precompiled binary on Windows (Japanese edition) but raises error on
Cygwin with the native Windows UI.

(set-default-font "MS ゴシック-14")

The reason is that lfFaceName member of LOGFONT structure is expected
to be encoded in ANSI code page, but Emacs encodes in or decodes as
the coding system specified in locale-coding-system variable.  It is
set to utf-8-unix on Cygwin and causes the above problem.

I think the below patch or similar modification would be needed.


=== modified file 'src/w32font.c'
--- src/w32font.c	2012-09-17 12:07:36 +0000
+++ src/w32font.c	2012-10-20 12:12:49 +0000
@@ -34,6 +34,15 @@
 #include "font.h"
 #include "w32font.h"
 
+/* From w32select.c */
+extern Lisp_Object QANSICP;
+
+#define ENCODE_ACP(str)					\
+  (code_convert_string_norecord (str, QANSICP, 1))
+
+#define DECODE_ACP(str)					\
+  (code_convert_string_norecord (str, QANSICP, 0))
+
 /* Cleartype available on Windows XP, cleartype_natural from XP SP1.
    The latter does not try to fit cleartype smoothed fonts into the
    same bounding box as the non-antialiased version of the font.
@@ -285,7 +294,7 @@
 Lisp_Object
 intern_font_name (char * string)
 {
-  Lisp_Object str = DECODE_SYSTEM (build_string (string));
+  Lisp_Object str = DECODE_ACP (build_string (string));
   int len = SCHARS (str);
   Lisp_Object obarray = check_obarray (Vobarray);
   Lisp_Object tem = oblookup (obarray, SDATA (str), len, len);
@@ -971,10 +980,10 @@
       }
     if (name)
       font->props[FONT_FULLNAME_INDEX]
-        = DECODE_SYSTEM (build_string (name));
+        = DECODE_ACP (build_string (name));
     else
       font->props[FONT_FULLNAME_INDEX]
-	= DECODE_SYSTEM (build_string (logfont.lfFaceName));
+	= DECODE_ACP (build_string (logfont.lfFaceName));
   }
 
   font->max_width = w32_font->metrics.tmMaxCharWidth;
@@ -2035,7 +2044,7 @@
       else if (SYMBOLP (tmp))
 	{
 	  strncpy (logfont->lfFaceName,
-		   SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE);
+		   SDATA (ENCODE_ACP (SYMBOL_NAME (tmp))), LF_FACESIZE);
 	  logfont->lfFaceName[LF_FACESIZE-1] = '\0';
 	}
     }
@@ -2131,7 +2140,7 @@
       if (NILP (family))
         continue;
       else if (SYMBOLP (family))
-        name = SDATA (ENCODE_SYSTEM (SYMBOL_NAME (family)));
+        name = SDATA (ENCODE_ACP (SYMBOL_NAME (family)));
       else
 	continue;
 
@@ -2511,7 +2520,7 @@
       || logfont_to_fcname (&lf, cf.iPointSize, buf, 100) < 0)
     return Qnil;
 
-  return DECODE_SYSTEM (build_string (buf));
+  return DECODE_ACP (build_string (buf));
 }
 
 static const char *const w32font_booleans [] = {

=== modified file 'src/w32select.c'
--- src/w32select.c	2012-10-11 00:32:25 +0000
+++ src/w32select.c	2012-10-20 06:11:00 +0000
@@ -117,7 +117,8 @@
    based on current system parameters. */
 static LCID DEFAULT_LCID;
 static UINT ANSICP, OEMCP;
-static Lisp_Object QUNICODE, QANSICP, QOEMCP;
+static Lisp_Object QUNICODE, QOEMCP;
+Lisp_Object QANSICP;
 
 /* A hidden window just for the clipboard management. */
 static HWND clipboard_owner;


-- 
Kazuhiro Ito




This bug report was last modified 4 years and 190 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.