浏览代码

text-freetype2: Make font lookup recursive on mac

On macs, some fonts can be in sub-folders of the font folder, and may
not properly be found.  This fixes that to detect directories and make
the lookup recursive.
jp9000 8 年之前
父节点
当前提交
e04ab3da7f
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      plugins/text-freetype2/find-font-cocoa.m

+ 10 - 1
plugins/text-freetype2/find-font-cocoa.m

@@ -32,7 +32,16 @@ static void add_path_fonts(NSFileManager *file_manager, NSString *path)
 	for (NSString *file in files) {
 		NSString *full_path = [path stringByAppendingPathComponent:file];
 
-		add_path_font(full_path.fileSystemRepresentation);
+		BOOL is_dir = FALSE;
+		bool folder_exists = [file_manager
+				fileExistsAtPath:full_path
+				isDirectory:&is_dir];
+
+		if (folder_exists && is_dir) {
+			add_path_fonts(file_manager, full_path);
+		} else {
+			add_path_font(full_path.fileSystemRepresentation);
+		}
 	}
 }