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