Commit 0bb4a0f93a8a241a3e499f62292b730fb340c339

Werner Lemberg 2002-06-19T15:57:55

* src/psaux/t1cmap.c (t1_cmap_custom_char_index, t1_cmap_custom_char_next): Fix index computation -- indices start with 0 and not with cmap->first. Provide default charmaps. * src/bdf/bdfdrivr.c (BDF_Face_Init), src/pcf/pcfdriver.c (PCF_Face_Init), src/pfr/pfrobjs.c (pfr_face_init), src/type1/t1objs (T1_Face_Init), src/winfonts/winfnt.c (FNT_Face_Init): Implement it.

diff --git a/ChangeLog b/ChangeLog
index 5cd786b..9443aaf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2002-06-18  Detlef Würkner  <TetiSoft@apg.lahn.de>
+
+	* src/psaux/t1cmap.c (t1_cmap_custom_char_index,
+	t1_cmap_custom_char_next): Fix index computation -- indices start
+	with 0 and not with cmap->first.
+
+	Provide default charmaps.
+
+	* src/bdf/bdfdrivr.c (BDF_Face_Init), src/pcf/pcfdriver.c
+	(PCF_Face_Init), src/pfr/pfrobjs.c (pfr_face_init),
+	src/type1/t1objs (T1_Face_Init), src/winfonts/winfnt.c
+	(FNT_Face_Init): Implement it.
+
 2002-06-17  Sven Neumann  <sven@gimp.org>
 
 	* src/pfr/pfrobjs.c (pfr_face_init): Fix typo.
@@ -43,7 +56,7 @@
 
 2002-06-14  Detlef Würkner  <TetiSoft@apg.lahn.de>
 
-	Add new cmap support to BDF driver
+	Add new cmap support to BDF driver.
 
 	* src/bdf/bdfdrivr.c (BDF_CMapRec) [FT_CONFIG_OPTION_USE_CMAPS]:
 	New structure.
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index 4a97e3d..e0e894b 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -448,6 +448,10 @@ THE SOFTWARE.
               }
 
               error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
+
+              /* Select default charmap */
+              if (root->num_charmaps)
+                root->charmap = root->charmaps[0];
             }
 
 #else /* !FT_CONFIG_OPTION_USE_CMAPS */
@@ -481,11 +485,15 @@ THE SOFTWARE.
 
 
           charmap.face        = FT_FACE( face );
-          charmap.encoding    = ft_encoding_none;
-          charmap.platform_id = 0;
+          charmap.encoding    = ft_encoding_adobe_standard;
+          charmap.platform_id = 7;
           charmap.encoding_id = 0;
 
           error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
+
+          /* Select default charmap */
+          if (root->num_charmaps)
+            root->charmap = root->charmaps[0];
         }
 
 #else /* !FT_CONFIG_OPTION_USE_CMAPS */
diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c
index c9e3972..c86bbfb 100644
--- a/src/pcf/pcfdriver.c
+++ b/src/pcf/pcfdriver.c
@@ -340,6 +340,10 @@ THE SOFTWARE.
         }
 
         error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
+
+        /* Select default charmap */
+        if (face->root.num_charmaps)
+          face->root.charmap = face->root.charmaps[0];
       }
 
 #else  /* !FT_CONFIG_OPTION_USE_CMAPS */
diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c
index 76a35d5..61e9afc 100644
--- a/src/pfr/pfrobjs.c
+++ b/src/pfr/pfrobjs.c
@@ -175,6 +175,10 @@
          charmap.encoding    = ft_encoding_unicode;
          
          FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
+
+         /* Select default charmap */
+         if (root->num_charmaps)
+           root->charmap = root->charmaps[0];
        }
      }
 
diff --git a/src/psaux/t1cmap.c b/src/psaux/t1cmap.c
index db3b968..0ddd3f5 100644
--- a/src/psaux/t1cmap.c
+++ b/src/psaux/t1cmap.c
@@ -197,12 +197,11 @@
                              FT_UInt32      char_code )
   {
     FT_UInt    result = 0;
-    FT_UInt32  idx;
 
 
-    idx = (FT_UInt32)( char_code - cmap->first );
-    if ( idx < cmap->count )
-      result = cmap->indices[idx];
+    if ( ( char_code >= cmap->first )                  &&
+         ( char_code < ( cmap->first + cmap->count ) ) )
+      result = cmap->indices[char_code];
 
     return result;
   }
@@ -214,7 +213,6 @@
   {
     FT_UInt    result = 0;
     FT_UInt32  char_code = *pchar_code;
-    FT_UInt32  idx;
 
 
     ++char_code;
@@ -222,10 +220,9 @@
     if ( char_code < cmap->first )
       char_code = cmap->first;
 
-    idx = (FT_UInt32)( char_code - cmap->first );
-    for ( ; idx < cmap->count; idx++, char_code++ )
+    for ( ; char_code < ( cmap->first + cmap->count ); char_code++ )
     {
-      result = cmap->indices[idx];
+      result = cmap->indices[char_code];
       if ( result != 0 )
         goto Exit;
     }
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 2755f25..5a6008d 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -485,6 +485,10 @@
 
         if ( clazz )
           FT_CMap_New( clazz, NULL, &charmap, NULL );
+
+        /* Select default charmap */
+        if (root->num_charmaps)
+          root->charmap = root->charmaps[0];
       }
     }
 
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index b2b44a6..5344c68 100644
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -548,7 +548,12 @@
                              NULL,
                              &charmap,
                              NULL );
-        if (error) goto Fail;
+        if ( error )
+          goto Fail;
+
+        /* Select default charmap */
+        if ( root->num_charmaps )
+          root->charmap = root->charmaps[0];
       }
 
 #else /* !FT_CONFIG_OPTION_USE_CMAPS */