changeset 89828:c734f0c6c3ca

(x_get_font_repertory): Fix for non-Unicode-bmp charset.
author Kenichi Handa <handa@m17n.org>
date Fri, 13 Feb 2004 06:40:15 +0000
parents 5dfe4d6f3b4a
children 7a60cfadbad9
files src/xterm.c
diffstat 1 files changed, 36 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Fri Feb 13 02:26:48 2004 +0000
+++ b/src/xterm.c	Fri Feb 13 06:40:15 2004 +0000
@@ -10085,8 +10085,8 @@
   Lisp_Object table;
   int min_byte1, max_byte1, min_byte2, max_byte2;
   int c;
-  struct charset *charset = (font_info->charset == charset_unicode
-			     ? NULL : CHARSET_FROM_ID (font_info->charset));
+  struct charset *charset = CHARSET_FROM_ID (font_info->charset);
+  int offset = CHARSET_OFFSET (charset);
 
   table = Fmake_char_table (Qnil, Qnil);
 
@@ -10097,7 +10097,17 @@
   if (min_byte1 == 0 && max_byte1 == 0)
     {
       if (! font->per_char || font->all_chars_exist == True)
-	char_table_set_range (table, min_byte2, max_byte2, Qt);
+	{
+	  if (offset >= 0)
+	    char_table_set_range (table, offset + min_byte2,
+				  offset + max_byte2, Qt);
+	  else
+	    for (; min_byte2 <= max_byte2; min_byte2++)
+	      {
+		c = DECODE_CHAR (charset, min_byte2);
+		CHAR_TABLE_SET (table, c, Qt);
+	      }
+	}
       else
 	{
 	  XCharStruct *pcm = font->per_char;
@@ -10110,12 +10120,13 @@
 		{
 		  if (from >= 0)
 		    {
-		      if (! charset)
-			char_table_set_range (table, from, i - 1, Qt);
+		      if (offset >= 0)
+			char_table_set_range (table, offset + from,
+					      offset + i - 1, Qt);
 		      else
 			for (; from < i; from++)
 			  {
-			    c = ENCODE_CHAR (charset, from);
+			    c = DECODE_CHAR (charset, from);
 			    CHAR_TABLE_SET (table, c, Qt);
 			  }
 		      from = -1;
@@ -10126,12 +10137,13 @@
 	    }
 	  if (from >= 0)
 	    {
-	      if (! charset)
-		char_table_set_range (table, from, i - 1, Qt);
+	      if (offset >= 0)
+		char_table_set_range (table, offset + from, offset + i - 1,
+				      Qt);
 	      else
 		for (; from < i; from++)
 		  {
-		    c = ENCODE_CHAR (charset, from);
+		    c = DECODE_CHAR (charset, from);
 		    CHAR_TABLE_SET (table, c, Qt);
 		  }
 	    }
@@ -10143,17 +10155,18 @@
 	{
 	  int i, j;
 
-	  if (! charset)
+	  if (offset >= 0)
 	    for (i = min_byte1; i <= max_byte1; i++)
-	      char_table_set_range (table,
-				    (i << 8) | min_byte2, (i << 8) | max_byte2,
-				    Qt);
+	      char_table_set_range
+		(table, offset + ((i << 8) | min_byte2),
+		 offset + ((i << 8) | max_byte2), Qt);
 	  else
 	    for (i = min_byte1; i <= max_byte1; i++)	    
 	      for (j = min_byte2; j <= max_byte2; j++)
 		{
 		  unsigned code = (i << 8) | j;
-		  c = ENCODE_CHAR (charset, code);
+		  c = DECODE_CHAR (charset, code);
+		  CHAR_TABLE_SET (table, c, Qt);
 		}
 	}
       else
@@ -10172,9 +10185,10 @@
 		    {
 		      if (from >= 0)
 			{
-			  if (! charset)
-			    char_table_set_range (table, (i << 8) | from,
-						  (i << 8) | (j - 1), Qt);
+			  if (offset >= 0)
+			    char_table_set_range
+			      (table, offset + ((i << 8) | from),
+			       offset + ((i << 8) | (j - 1)), Qt);
 			  else
 			    {
 			      for (; from < j; from++)
@@ -10192,15 +10206,16 @@
 		}
 	      if (from >= 0)
 		{
-		  if (! charset)
-		    char_table_set_range (table, (i << 8) | from,
-					  (i << 8) | (j - 1), Qt);
+		  if (offset >= 0)
+		    char_table_set_range
+		      (table, offset + ((i << 8) | from),
+		       offset + ((i << 8) | (j - 1)), Qt);
 		  else
 		    {
 		      for (; from < j; from++)
 			{
 			  unsigned code = (i << 8) | from;
-			  c = ENCODE_CHAR (charset, code);
+			  c = DECODE_CHAR (charset, code);
 			  CHAR_TABLE_SET (table, c, Qt);
 			}
 		    }