diff src/xfns.c @ 89483:2f877ed80fa6

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Mon, 08 Sep 2003 12:53:41 +0000
parents 375f2633d815 ffa18ef18e45
children 483f5ce6ca7a
line wrap: on
line diff
--- a/src/xfns.c	Mon Sep 08 11:56:09 2003 +0000
+++ b/src/xfns.c	Mon Sep 08 12:53:41 2003 +0000
@@ -42,6 +42,7 @@
 #include "keyboard.h"
 #include "blockinput.h"
 #include <epaths.h>
+#include "character.h"
 #include "charset.h"
 #include "coding.h"
 #include "fontset.h"
@@ -1838,49 +1839,29 @@
      int *text_bytes, *stringp;
      int selectionp;
 {
-  unsigned char *str = SDATA (string);
-  int chars = SCHARS (string);
-  int bytes = SBYTES (string);
-  int charset_info;
-  int bufsize;
-  unsigned char *buf;
+  int result = string_xstring_p (string);
   struct coding_system coding;
   extern Lisp_Object Qcompound_text_with_extensions;
 
-  charset_info = find_charset_in_text (str, chars, bytes, NULL, Qnil);
-  if (charset_info == 0)
+  if (result == 0)
     {
       /* No multibyte character in OBJ.  We need not encode it.  */
-      *text_bytes = bytes;
+      *text_bytes = SBYTES (string);
       *stringp = 1;
-      return str;
+      return SDATA (string);
     }
 
   setup_coding_system (coding_system, &coding);
-  if (selectionp
-      && SYMBOLP (coding.pre_write_conversion)
-      && !NILP (Ffboundp (coding.pre_write_conversion)))
-    {
-      string = run_pre_post_conversion_on_str (string, &coding, 1);
-      str = SDATA (string);
-      chars = SCHARS (string);
-      bytes = SBYTES (string);
-    }
-  coding.src_multibyte = 1;
-  coding.dst_multibyte = 0;
-  coding.mode |= CODING_MODE_LAST_BLOCK;
-  if (coding.type == coding_type_iso2022)
-    coding.flags |= CODING_FLAG_ISO_SAFE;
+  coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK);
   /* We suppress producing escape sequences for composition.  */
-  coding.composing = COMPOSITION_DISABLED;
-  bufsize = encoding_buffer_size (&coding, bytes);
-  buf = (unsigned char *) xmalloc (bufsize);
-  encode_coding (&coding, str, buf, bytes, bufsize);
+  coding.common_flags &= ~CODING_ANNOTATION_MASK;
+  coding.dst_bytes = SCHARS (string) * 2;
+  coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
+  encode_coding_object (&coding, string, 0, 0,
+			SCHARS (string), SBYTES (string), Qnil);
   *text_bytes = coding.produced;
-  *stringp = (charset_info == 1
-	      || (!EQ (coding_system, Qcompound_text)
-		  && !EQ (coding_system, Qcompound_text_with_extensions)));
-  return buf;
+  *stringp = (result == 1 || !EQ (coding_system, Qcompound_text));
+  return coding.destination;
 }
 
 
@@ -3322,35 +3303,39 @@
 
     font = x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
 
-    BLOCK_INPUT;
-    /* First, try whatever font the caller has specified.  */
-    if (STRINGP (font))
-      {
-	tem = Fquery_fontset (font, Qnil);
-	if (STRINGP (tem))
-	  font = x_new_fontset (f, SDATA (tem));
-	else
-	  font = x_new_font (f, SDATA (font));
-      }
-
-    /* Try out a font which we hope has bold and italic variations.  */
-    if (!STRINGP (font))
-      font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
+    /* If the caller has specified no font, try out fonts which we
+       hope have bold and italic variations.  */
     if (!STRINGP (font))
-      font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
-    if (! STRINGP (font))
-      font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
-    if (! STRINGP (font))
-      /* This was formerly the first thing tried, but it finds too many fonts
-	 and takes too long.  */
-      font = x_new_font (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
-    /* If those didn't work, look for something which will at least work.  */
-    if (! STRINGP (font))
-      font = x_new_font (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
-    UNBLOCK_INPUT;
-    if (! STRINGP (font))
-      font = build_string ("fixed");
-
+      {
+	char *names[]
+	  = { "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1",
+	      "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1",
+	      "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1",
+	      /* This was formerly the first thing tried, but it finds
+		 too many fonts and takes too long.  */
+	      "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1",
+	      /* If those didn't work, look for something which will
+		 at least work.  */
+	      "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1",
+	      NULL };
+	int i;
+
+	BLOCK_INPUT;
+	for (i = 0; names[i]; i++)
+	  {
+	    Lisp_Object list;
+
+	    list = x_list_fonts (f, build_string (names[i]), 0, 1);
+	    if (CONSP (list))
+	      {
+		font = XCAR (list);
+		break;
+	      }
+	  }
+	UNBLOCK_INPUT;
+	if (! STRINGP (font))
+	  font = build_string ("fixed");
+      }
     x_default_parameter (f, parms, Qfont, font,
 			 "font", "Font", RES_TYPE_STRING);
   }
@@ -9885,7 +9870,7 @@
       {
 	tem = Fquery_fontset (font, Qnil);
 	if (STRINGP (tem))
-	  font = x_new_fontset (f, SDATA (tem));
+	  font = x_new_fontset (f, tem);
 	else
 	  font = x_new_font (f, SDATA (font));
       }
@@ -10928,6 +10913,7 @@
   find_ccl_program_func = x_find_ccl_program;
   query_font_func = x_query_font;
   set_frame_fontset_func = x_set_font;
+  get_font_repertory_func = x_get_font_repertory;
   check_window_system_func = check_x;
 
   /* Images.  */