88722b
diff -ruN -x '*o' -x '*~' -x ttmkfdir -x parser.cpp ttmkfdir-3.0.9.orig/ttf.cpp ttmkfdir-3.0.9/ttf.cpp
88722b
--- ttmkfdir-3.0.9.orig/ttf.cpp	2006-11-29 15:46:55.000000000 +0900
88722b
+++ ttmkfdir-3.0.9/ttf.cpp	2006-11-29 17:21:40.000000000 +0900
88722b
@@ -70,7 +70,6 @@
88722b
 Face::Face (const std::string &filename)
88722b
 {
88722b
     FT_Error fterror;
88722b
-    string header_enc("-");
88722b
     int face_id, face_count;
88722b
 
88722b
     string::size_type pos = filename.rfind("/");
88722b
@@ -98,29 +97,13 @@
88722b
         if ((post = (TT_Postscript *) FT_Get_Sfnt_Table(face, ft_sfnt_post)) == 0){
88722b
             std::cout << "Warning: Can't get POST table : " << FileName << "(" << FT_Err_Post_Table_Missing << ")" << std::endl;
88722b
 	    return;
88722b
-    }
88722b
+	}
88722b
 
88722b
         if ((os2 = (TT_OS2 *) FT_Get_Sfnt_Table(face, ft_sfnt_os2)) == 0) {
88722b
             std::cout << "Warning: Can't get OS2 table : " << FileName << "(" << FT_Err_Table_Missing << ")" << std::endl;
88722b
 	    return;
88722b
         }
88722b
 
88722b
-        for (int j = 0; j < 32; j++) {
88722b
-	    switch (os2->ulCodePageRange1 & (1 << j)) {
88722b
-	        case TT_CODEPAGE_RANGE_932: /* Japanese */
88722b
-                    header_enc = "ji";
88722b
-	            break;
88722b
-	        case TT_CODEPAGE_RANGE_936: /* Simplified Chinese */
88722b
-                    header_enc = "gb";
88722b
-	            break;
88722b
-	        case TT_CODEPAGE_RANGE_949: /* Korean Wansung */
88722b
-                    header_enc = "ks";
88722b
-	            break;
88722b
-	        case TT_CODEPAGE_RANGE_950: /* Traditional Chinese */
88722b
-                    header_enc = "big";
88722b
-	            break;
88722b
-            }
88722b
-        }
88722b
         /*
88722b
          * Iterate over all cmap entries.
88722b
          */
88722b
@@ -148,25 +131,50 @@
88722b
 	     */
88722b
 	    typedef Encodings_t::const_iterator MI;
88722b
 	    std::pair<MI, MI> bounds = Encodings::instance()->equal_range (key);
88722b
+	    bool need_non_cjk_encoding = true;
88722b
 
88722b
 	    /*
88722b
 	     * then look whether each of these encodings is present in this cmap.
88722b
 	     */
88722b
-	    for (Encodings_t::const_iterator i = bounds.first; i != bounds.second; i++) {
88722b
-	        if (MappingPresent (cmapidx, 
88722b
-	    		        i->second->mappings[key], 
88722b
-				i->second->enc_size,
88722b
-			       	i->second->start_code, 
88722b
-				(header_enc.compare("-")?((i->second->names[0].find(header_enc) != string::npos)?1:0):1)
88722b
-		    	        )) {
88722b
-		    /*
88722b
-		     * if the mapping is present, add all xlfd names for this mapping to the
88722b
-		     * list of available font names.
88722b
-		     */
88722b
-		    for (unsigned int k = 0; k < i->second->names.size (); k++) {
88722b
-	                add_entries (i->second->names[k],face_id);
88722b
+	    for (int j = 0; j < 32; j++) {
88722b
+	        string header_enc("-");
88722b
+
88722b
+		switch (os2->ulCodePageRange1 & (1 << j)) {
88722b
+	            case TT_CODEPAGE_RANGE_932: /* Japanese */
88722b
+		        header_enc = "ji";
88722b
+		        break;
88722b
+	            case TT_CODEPAGE_RANGE_936: /* Simplified Chinese */
88722b
+		        header_enc = "gb";
88722b
+			break;
88722b
+	            case TT_CODEPAGE_RANGE_949: /* Korean Wansung */
88722b
+                        header_enc = "ks";
88722b
+			break;
88722b
+	            case TT_CODEPAGE_RANGE_950: /* Traditional Chinese */
88722b
+		        header_enc = "big";
88722b
+			break;
88722b
+		    default:
88722b
+		      if (need_non_cjk_encoding)
88722b
+			  need_non_cjk_encoding = false;
88722b
+		      else
88722b
+			  continue;
88722b
+		      break;
88722b
+		}
88722b
+		for (Encodings_t::const_iterator i = bounds.first; i != bounds.second; i++) {
88722b
+		    if (MappingPresent (cmapidx, 
88722b
+					i->second->mappings[key], 
88722b
+					i->second->enc_size,
88722b
+					i->second->start_code, 
88722b
+					(header_enc.compare("-")?((i->second->names[0].find(header_enc) != string::npos)?1:0):1)
88722b
+					)) {
88722b
+		        /*
88722b
+			 * if the mapping is present, add all xlfd names for this mapping to the
88722b
+			 * list of available font names.
88722b
+			 */
88722b
+		        for (unsigned int k = 0; k < i->second->names.size (); k++) {
88722b
+			    add_entries (i->second->names[k],face_id);
88722b
+			}
88722b
 		    }
88722b
-	        }
88722b
+		}
88722b
 	    }
88722b
         }
88722b