[FriBidi-commit] fribidi/charset fribidi-char-sets-cap-rtl.c, 1.9, 1.10

Behdad Esfahbod behdad@freedesktop.org
Sun Jan 9 22:43:55 PST 2005


Update of /cvs/fribidi/fribidi/charset
In directory gabe:/tmp/cvs-serv5916

Modified Files:
	fribidi-char-sets-cap-rtl.c 
Log Message:
Better conversion table from CapRTL to Unicode.


Index: fribidi-char-sets-cap-rtl.c
===================================================================
RCS file: /cvs/fribidi/fribidi/charset/fribidi-char-sets-cap-rtl.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- fribidi-char-sets-cap-rtl.c	15 Jun 2004 11:52:02 -0000	1.9
+++ fribidi-char-sets-cap-rtl.c	10 Jan 2005 06:43:53 -0000	1.10
@@ -80,15 +80,24 @@
   FriBidiCharType to_type[_FRIBIDI_NUM_TYPES];
   int num_types = 0, j, count = 0;
   FriBidiCharType i;
+  char mark[CAPRTL_CHARS];
 
   caprtl_to_unicode =
     (FriBidiChar *) fribidi_malloc (CAPRTL_CHARS *
 				    sizeof caprtl_to_unicode[0]);
   for (i = 0; i < CAPRTL_CHARS; i++)
-    if (fribidi_get_mirror_char (i, NULL))
+    if (CapRTLCharTypes[i] == fribidi_get_bidi_type(i))
+    {
       caprtl_to_unicode[i] = i;
+      mark[i] = 1;
+    }
     else
       {
+	caprtl_to_unicode[i] = FRIBIDI_UNICODE_CHARS;
+	mark[i] = 0;
+        if (fribidi_get_mirror_char (i, NULL))
+	  DBG ("warning: I could not map mirroring character map to itself in CapRTL");
+
 	for (j = 0; j < num_types; j++)
 	  if (to_type[j] == CapRTLCharTypes[i])
 	    break;
@@ -101,25 +110,36 @@
 	request[j]++;
 	count++;
       }
-  for (i = 1; i < 0x10000 && count; i++)	/* Assign BMP chars to CapRTL entries */
-    if (!fribidi_get_mirror_char (i, NULL))
+  for (i = 0; i < 0x10000 && count; i++)	/* Assign BMP chars to CapRTL entries */
+    if (!fribidi_get_mirror_char (i, NULL) && !(i < CAPRTL_CHARS && mark[i]))
       {
 	int j, k;
+	FriBidiCharType t = fribidi_get_bidi_type (i);
 	for (j = 0; j < num_types; j++)
-	  if (to_type[j] == fribidi_get_bidi_type (i))
+	  if (to_type[j] == t)
 	    break;
 	if (!request[j])	/* Do not need this type */
 	  continue;
 	for (k = 0; k < CAPRTL_CHARS; k++)
-	  if (!caprtl_to_unicode[k] && to_type[j] == CapRTLCharTypes[k])
-	    break;
-	if (k < CAPRTL_CHARS)
+	  if (caprtl_to_unicode[k] == FRIBIDI_UNICODE_CHARS && to_type[j] == CapRTLCharTypes[k])
 	  {
 	    request[j]--;
 	    count--;
 	    caprtl_to_unicode[k] = i;
+	    break;
 	  }
       }
+  if (count)
+  {
+    int j;
+
+    DBG ("warning: could not find a mapping for CapRTL to Unicode:");
+    for (j = 0; j < num_types; j++)
+      if (request[j])
+	DBG2 ("  need this type: %s", fribidi_get_bidi_type_name
+	    (to_type[j]));
+	
+  }
 }
 
 static char



More information about the fribidi-commit mailing list