unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs-unicode-2: w32_font_match
@ 2004-11-02  6:09 KOBAYASHI Yasuhiro
  2004-11-02  8:54 ` Jason Rumney
  0 siblings, 1 reply; 2+ messages in thread
From: KOBAYASHI Yasuhiro @ 2004-11-02  6:09 UTC (permalink / raw)
  Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]

It seems that w32_font_match() dose't work correctly in the
case of using font name with multibyte in emacs-unicode-2.

The variable 'encoded_font_name' may include the charactor
'-', then 'xlfd_strip_height (font_name_copy)' return -1, so
I think that string_make_unibyte should not be used.

For example:
(create-fontset-from-fontset-spec
 "-*-Courier New-normal-r-*-*-12-*-*-*-c-*-fontset-TTG12c,
 japanese-jisx0208:-*-MS ゴシック-*-*-*-*-*-*-*-*-*-*-jisx0208-sjis,
 latin-jisx0201:-*-MS ゴシック-*-*-*-*-*-*-*-*-*-*-jisx0208-sjis,
 katakana-jisx0201:-*-MS ゴシック-*-*-*-*-*-*-*-*-*-*-jisx0208-sjis" t)

(gdb) b  w32_font_match
Breakpoint 4, w32_font_match (fontname=0x83e020 "-outline-?ュ?ウ 綵202エ綵202キ綵203\203綵202ッ-normal-r-normal-normal-12-90-96-96-c-*-jisx0208-sjis", pattern=0x2dcc9b0 "-outline-hgp藹211オ鐔213ア隗\222?コ?\236?シ?ッ?クub-normal-r-normal-normal-12-*-96-96-p-*-jisx0208-sjis") at w32fns.c:5809
(gdb) p encoded_font_name 
$3 = 35884144
(gdb) xstring 
$4 = (struct Lisp_String *) 0x2238c70
"-outline--3 エキテッ-normal-r-normal-normal-12-90-96-96-c-*-jisx0208-sjis"

The attached patch use fast_string_match for comparing
font names, just like

2004-10-18  Kenichi Handa  <handa@m17n.org>

	* fontset.c (fs_load_font): Use fast_string_match_ignore_case for
	comparing font names.
	(fs_query_fontset): Use fast_string_match for comparing fontset names.
	(list_fontsets): Likewise.

	* search.c (fast_string_match_ignore_case): New function.

	* lisp.h (fast_string_match_ignore_case): Extern it.


-- 
KOBAYASHI Yasuhiro <kobayays@otsukakj.co.jp>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: w32fns.c --]
[-- Type: text/x-patch, Size: 1259 bytes --]

Index: src/w32fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32fns.c,v
retrieving revision 1.219.2.11
diff -u -r1.219.2.11 w32fns.c
--- src/w32fns.c	22 Oct 2004 10:13:34 -0000	1.219.2.11
+++ src/w32fns.c	1 Nov 2004 15:41:37 -0000
@@ -5667,14 +5667,12 @@
     char * fontname;
     char * pattern;
 {
-  char *font_name_copy;
-  char *ptr;
-  Lisp_Object encoded_font_name;
   char *regex = alloca (strlen (pattern) * 2 + 3);
+  char *font_name_copy = alloca (strlen (fontname) + 1);
+  char *ptr;
 
-  /* Convert fontname to unibyte for match.  */
-  encoded_font_name = string_make_unibyte (build_string (fontname));
-  font_name_copy = SDATA (encoded_font_name);
+   /* Copy fontname so we can modify it during comparison.  */
+  strcpy (font_name_copy, fontname);
 
   ptr = regex;
   *ptr++ = '^';
@@ -5712,8 +5710,8 @@
       return FALSE;
   }
 
-  return (fast_c_string_match_ignore_case (build_string (regex),
-                                           font_name_copy) >= 0);
+  return (fast_string_match_ignore_case (build_string (regex),
+                                         build_string (fontname)) >= 0);
 }
 
 /* Callback functions, and a structure holding info they need, for

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Emacs-unicode-2: w32_font_match
  2004-11-02  6:09 Emacs-unicode-2: w32_font_match KOBAYASHI Yasuhiro
@ 2004-11-02  8:54 ` Jason Rumney
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Rumney @ 2004-11-02  8:54 UTC (permalink / raw)
  Cc: emacs-devel, Kenichi Handa

KOBAYASHI Yasuhiro <kobayays@otsukakj.co.jp> writes:

> The attached patch use fast_string_match for comparing
> font names.

Thank you, I installed it.

-  return (fast_c_string_match_ignore_case (build_string (regex),
-                                           font_name_copy) >= 0);
+  return (fast_string_match_ignore_case (build_string (regex),
+                                         build_string (fontname)) >= 0);

Shouldn't that last line be "build_string (font_name_copy)) >= 0);"?

Otherwise you create font_name_copy, modify it, then never use it.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-11-02  8:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-02  6:09 Emacs-unicode-2: w32_font_match KOBAYASHI Yasuhiro
2004-11-02  8:54 ` Jason Rumney

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).