From: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
To: 12693@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 [thread overview]
Message-ID: <87y5j0ddgj.wl%%xmue@d1.dion.ne.jp> (raw)
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
next reply other threads:[~2012-10-20 21:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-20 21:46 Kazuhiro Ito [this message]
2012-10-23 11:52 ` bug#12693: 24.2.50; src/w32font.c should depend on ANSI code page Jason Rumney
2012-10-23 13:05 ` Kazuhiro Ito
2012-10-23 16:22 ` Eli Zaretskii
2012-10-25 21:18 ` Daniel Colascione
2012-10-26 7:30 ` Eli Zaretskii
2012-10-23 16:12 ` Eli Zaretskii
2020-09-13 16:16 ` bug#12693: [cygwin] Setting fonts with non-ascii names throws error quit Lars Ingebrigtsen
2020-09-14 8:40 ` Kazuhiro Ito
2020-09-14 10:52 ` Lars Ingebrigtsen
2020-09-14 11:38 ` Kazuhiro Ito
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y5j0ddgj.wl%%xmue@d1.dion.ne.jp \
--to=kzhr@d1.dion.ne.jp \
--cc=12693@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.