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