changeset 88418:0e981bfea920

Include "character.h". (x_encode_char): New argument CHARSET. Caller changed. (x_get_char_face_and_encoding): Call ENCODE_CHAR instead of SPLIT_CHAR. (x_get_glyph_face_and_encoding): Likewise. (x_produce_glyphs): Don't check Vnonascii_translation_table Call CHAR_WIDTH instead of CHARSET_WIDTH. (XTread_socket): Adjusted for the new code-conversion API. (x_new_font): Adjusted for the change of FS_LOAD_FONT. (x_load_font): Adjusted for the change of struct font.
author Kenichi Handa <handa@m17n.org>
date Fri, 01 Mar 2002 04:14:58 +0000
parents ad2a9fd4da9b
children c04be57b2859
files src/xterm.c
diffstat 1 files changed, 61 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Fri Mar 01 03:34:44 2002 +0000
+++ b/src/xterm.c	Fri Mar 01 04:14:58 2002 +0000
@@ -68,6 +68,7 @@
 /* #include <sys/param.h>  */
 
 #include "charset.h"
+#include "character.h"
 #include "coding.h"
 #include "ccl.h"
 #include "frame.h"
@@ -1137,7 +1138,8 @@
 static struct face *x_get_char_face_and_encoding P_ ((struct frame *, int,
 						      int, XChar2b *, int));
 static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *));
-static void x_encode_char P_ ((int, XChar2b *, struct font_info *));
+static void x_encode_char P_ ((int, XChar2b *, struct font_info *,
+			       struct charset *));
 static void x_append_glyph P_ ((struct it *));
 static void x_append_composite_glyph P_ ((struct it *));
 static void x_append_stretch_glyph P_ ((struct it *it, Lisp_Object,
@@ -1221,12 +1223,12 @@
    the two-byte form of C.  Encoding is returned in *CHAR2B.  */
 
 static INLINE void
-x_encode_char (c, char2b, font_info)
+x_encode_char (c, char2b, font_info, charset)
      int c;
      XChar2b *char2b;
      struct font_info *font_info;
-{
-  int charset = CHAR_CHARSET (c);
+     struct charset *charset;
+{
   XFontStruct *font = font_info->font;
 
   /* FONT_INFO may define a scheme by which to encode byte1 and byte2.
@@ -1239,17 +1241,17 @@
 
       if (CHARSET_DIMENSION (charset) == 1)
 	{
-	  ccl->reg[0] = charset;
+	  ccl->reg[0] = CHARSET_ID (charset);
 	  ccl->reg[1] = char2b->byte2;
 	}
       else
 	{
-	  ccl->reg[0] = charset;
+	  ccl->reg[0] = CHARSET_ID (charset);
 	  ccl->reg[1] = char2b->byte1;
 	  ccl->reg[2] = char2b->byte2;
 	}
       
-      ccl_driver (ccl, NULL, NULL, 0, 0, NULL);
+      ccl_driver (ccl, NULL, NULL, 0, 0);
       
       /* We assume that MSBs are appropriately set/reset by CCL
 	 program.  */
@@ -1258,11 +1260,11 @@
       else
 	char2b->byte1 = ccl->reg[1], char2b->byte2 = ccl->reg[2];
     }
-  else if (font_info->encoding[charset])
+  else if (font_info->encoding_type)
     {
       /* Fixed encoding scheme.  See fontset.h for the meaning of the
 	 encoding numbers.  */
-      int enc = font_info->encoding[charset];
+      unsigned char enc = font_info->encoding_type;
       
       if ((enc == 1 || enc == 2)
 	  && CHARSET_DIMENSION (charset) == 2)
@@ -1303,26 +1305,20 @@
       char2b->byte1 = 0;
       char2b->byte2 = c;
     }
-  else
-    {
-      int c1, c2, charset;
-      
-      /* Split characters into bytes.  If c2 is -1 afterwards, C is
-	 really a one-byte character so that byte1 is zero.  */
-      SPLIT_CHAR (c, charset, c1, c2);
-      if (c2 > 0)
-	char2b->byte1 = c1, char2b->byte2 = c2;
+  else if (face->font != NULL)
+    {
+      struct font_info *font_info
+	= FONT_INFO_FROM_ID (f, face->font_info_id);
+      struct charset *charset = CHARSET_FROM_ID (font_info->charset);
+      unsigned code = ENCODE_CHAR (charset, c);
+      
+      if (CHARSET_DIMENSION (charset) == 1)
+	char2b->byte1 = 0, char2b->byte2 = code;
       else
-	char2b->byte1 = 0, char2b->byte2 = c1;
+	char2b->byte1 = code >> 8, char2b->byte2 = code & 0xFF;
 
       /* Maybe encode the character in *CHAR2B.  */
-      if (face->font != NULL)
-	{
-	  struct font_info *font_info
-	    = FONT_INFO_FROM_ID (f, face->font_info_id);
-	  if (font_info)
-	    x_encode_char (c, char2b, font_info);
-	}
+      x_encode_char (c, char2b, font_info, charset);
     }
 
   /* Make sure X resources of the face are allocated.  */
@@ -1368,24 +1364,22 @@
     }
   else
     {
-      int c1, c2, charset;
-      
-      /* Split characters into bytes.  If c2 is -1 afterwards, C is
-	 really a one-byte character so that byte1 is zero.  */
-      SPLIT_CHAR (glyph->u.ch, charset, c1, c2);
-      if (c2 > 0)
-	char2b->byte1 = c1, char2b->byte2 = c2;
-      else
-	char2b->byte1 = 0, char2b->byte2 = c1;
-
-      /* Maybe encode the character in *CHAR2B.  */
-      if (charset != CHARSET_ASCII)
-	{
-	  struct font_info *font_info
-	    = FONT_INFO_FROM_ID (f, face->font_info_id);
-	  if (font_info)
+      struct font_info *font_info
+	= FONT_INFO_FROM_ID (f, face->font_info_id);
+      if (font_info)
+	{
+	  struct charset *charset = CHARSET_FROM_ID (font_info->charset);
+	  unsigned code = ENCODE_CHAR (charset, glyph->u.ch);
+      
+	  if (CHARSET_DIMENSION (charset) == 1)
+	    char2b->byte1 = 0, char2b->byte2 = code;
+	  else
+	    char2b->byte1 = code >> 8, char2b->byte2 = code & 0xFF;
+
+	  /* Maybe encode the character in *CHAR2B.  */
+	  if (CHARSET_ID (charset) != charset_ascii)
 	    {
-	      x_encode_char (glyph->u.ch, char2b, font_info);
+	      x_encode_char (glyph->u.ch, char2b, font_info, charset);
 	      if (two_byte_p)
 		*two_byte_p
 		  = ((XFontStruct *) (font_info->font))->max_byte1 > 0;
@@ -1817,9 +1811,7 @@
       if (!ASCII_BYTE_P (it->c))
 	{
 	  if (unibyte_display_via_language_environment
-	      && SINGLE_BYTE_CHAR_P (it->c)
-	      && (it->c >= 0240
-		  || !NILP (Vnonascii_translation_table)))
+	      && SINGLE_BYTE_CHAR_P (it->c))
 	    {
 	      it->char_to_display = unibyte_char_to_multibyte (it->c);
 	      it->multibyte_p = 1;
@@ -1985,17 +1977,15 @@
 
 	  /* If we found a font, this font should give us the right
 	     metrics.  If we didn't find a font, use the frame's
-	     default font and calculate the width of the character
-	     from the charset width; this is what old redisplay code
-	     did.  */
+	     default font and calculate the width of the character by
+	     multiplying the width of font by the width of the
+	     character.  */
 	  pcm = x_per_char_metric (font, &char2b);
 	  if (font_not_found_p || !pcm)
 	    {
-	      int charset = CHAR_CHARSET (it->char_to_display);
-
 	      it->glyph_not_available_p = 1;
 	      it->pixel_width = (FONT_WIDTH (FRAME_FONT (it->f))
-				 * CHARSET_WIDTH (charset));
+				 * CHAR_WIDTH (it->char_to_display));
 	      it->phys_ascent = font->ascent + boff;
 	      it->phys_descent = font->descent - boff;
 	    }
@@ -2058,10 +2048,7 @@
       /* Maybe translate single-byte characters to multibyte.  */
       it->char_to_display = it->c;
       if (unibyte_display_via_language_environment
-	  && SINGLE_BYTE_CHAR_P (it->c)
-	  && (it->c >= 0240
-	      || (it->c >= 0200
-		  && !NILP (Vnonascii_translation_table))))
+	  && it->c >= 0200)
 	{
 	  it->char_to_display = unibyte_char_to_multibyte (it->c);
 	}
@@ -9992,7 +9979,7 @@
   /* The input is converted to events, thus we can't handle
      composition.  Anyway, there's no XIM that gives us composition
      information.  */
-  coding.composing = COMPOSITION_DISABLED;
+  coding.common_flags &= ~CODING_ANNOTATION_MASK;
 
   /* Find the display we are supposed to read input for.
      It's the one communicating on descriptor SD.  */
@@ -10664,8 +10651,7 @@
 			      event.xkey.keycode != 0
 			      /* or the current locale doesn't request
 				 decoding of the intup data, ... */
-			      || coding.type == coding_type_raw_text
-			      || coding.type == coding_type_no_conversion)
+			      || ! CODING_REQUIRE_DECODING (&coding))
 			    {
 			      /* ... we can use the input data as is.  */
 			      nchars = nbytes;
@@ -10673,17 +10659,23 @@
 			  else
 			    { 
 			      /* We have to decode the input data.  */
-			      int require;
-			      unsigned char *p;
-
-			      require = decoding_buffer_size (&coding, nbytes);
-			      p = (unsigned char *) alloca (require);
+			      coding.destination
+				= (unsigned char *) malloc (nbytes);
+			      if (! coding.destination)
+				break;
+			      coding.dst_bytes = nbytes;
 			      coding.mode |= CODING_MODE_LAST_BLOCK;
-			      decode_coding (&coding, copy_bufptr, p,
-					     nbytes, require);
+			      decode_coding_c_string (&coding, copy_bufptr,
+						      nbytes, Qnil);
 			      nbytes = coding.produced;
 			      nchars = coding.produced_char;
-			      copy_bufptr = p;
+			      if (copy_bufsiz < nbytes)
+				{
+				  copy_bufsiz = nbytes;
+				  copy_bufptr = (char *) alloca (nbytes);
+				}
+			      bcopy (coding.destination, copy_bufptr, nbytes);
+			      free (coding.destination);
 			    }
 
 			  /* Convert the input data to a sequence of
@@ -12198,7 +12190,7 @@
      register char *fontname;
 {
   struct font_info *fontp
-    = FS_LOAD_FONT (f, 0, fontname, -1);
+    = FS_LOAD_FONT (f, fontname);
 
   if (!fontp)
     return Qnil;
@@ -14342,7 +14334,7 @@
        uses this font.  So, we set information in fontp->encoding[1]
        which is never used by any charset.  If mapping can't be
        decided, set FONT_ENCODING_NOT_DECIDED.  */
-    fontp->encoding[1]
+    fontp->encoding_type
       = (font->max_byte1 == 0
 	 /* 1-byte font */
 	 ? (font->min_char_or_byte2 < 0x80