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