Fonts AppleScript-列出所有字体

Fonts AppleScript-列出所有字体,fonts,applescript,Fonts,Applescript,我已经尝试这么做很长时间了,但还没有找到一个有效的方法。目前,我一直在尝试列出我知道的所有字体,如下所示: set the font_list to {"Arial","Comic Sans MS","Arial Black",...} 但是写所有的字体需要永远的时间,我知道Mac上有很多字体。有没有更有效的方法来获取系统上的所有字体,在文本文档中写入一堆内容,然后将每个连续行的字体设置为下一个字体(即,第1行的字体是字体1,第2行的字体是字体2,等等)?Mac OS X有很多字体,你是对的。

我已经尝试这么做很长时间了,但还没有找到一个有效的方法。目前,我一直在尝试列出我知道的所有字体,如下所示:

set the font_list to {"Arial","Comic Sans MS","Arial Black",...}

但是写所有的字体需要永远的时间,我知道Mac上有很多字体。有没有更有效的方法来获取系统上的所有字体,在文本文档中写入一堆内容,然后将每个连续行的字体设置为下一个字体(即,第1行的字体是字体1,第2行的字体是字体2,等等)?

Mac OS X有很多字体,你是对的。这些字体通过四个或更多文件夹分发,具体取决于软件安装和计算机上的用户帐户数

+我一直在尝试做同样的事情,所以我写了一个小脚本来完成这项工作。它从四/五个不同的位置提取字体,写入文本文档,然后更改字体。但是,当您运行它时,您的系统可能会开始滞后(就像我刚才所做的那样)。但这种滞后是值得的!以下是脚本:

--"get all the fonts on the system" display dialog "WARNING" & return & return & "This script may cause your computer to lag. Are you sure you want to proceed with the font sampler?" with icon caution set the font_folders to {"/Users/" & the short user name of (system info) & "/Library/Fonts/", "/Library/Fonts/", "/Network/Library/Fonts/", "/System/Library/Fonts/", "/System Folder/Fonts/"} set these_fonts to {} repeat with this_font_folder in the font_folders try tell application "Finder" to set the end of these_fonts to every item of ((this_font_folder as POSIX file) as alias) end try end repeat --"write a bunch of stuff in a text document" tell application "TextEdit" activate set zoomed of the front window to true set the name of the front window to "Font Sampler" end tell repeat with this_font in these_fonts tell application "Finder" to set this_font to the name of this_font tell application "TextEdit" to set the text of document 1 to the text of document 1 & this_font & ": The quick brown fox jumps over the lazy dog." & return end repeat --"set the font of each consecutive line to the next font (i.e. Line 1's font is Font 1, Line 2's font is Font 2, etc.)" repeat with i from 1 to the count of these_fonts tell application "Finder" to set this_font to the name of item i of these_fonts tell application "TextEdit" to tell paragraph i of the text of document 1 to set the font to this_font end repeat --“获取系统上的所有字体” 显示对话框“警告”&return&return&“此脚本可能会导致计算机延迟。是否确实要继续使用字体采样器?”并带有图标警告 将font_文件夹设置为{“/Users/”&系统信息的短用户名和“/Library/Fonts/”、“/Library/Fonts/”、“/Network/Library/Fonts/”、“/system/Library/Fonts/”、“/system Folder/Fonts/”} 将这些字体设置为{} 在font\u文件夹中重复此文件夹 尝试 告诉应用程序“Finder”将这些字体的结尾设置为((此字体文件夹作为POSIX文件)的每一项作为别名) 结束尝试 结束重复 --“在文本文档中写一堆东西” 告诉应用程序“文本编辑” 激活 将前窗口的缩放设置为true 将前窗口的名称设置为“字体采样器” 结束语 在这些字体中重复使用此字体 告诉应用程序“Finder”将此字体设置为此字体的名称 告诉应用程序“textexdit”将文档1的文本设置为文档1的文本&此字体&“:快速棕色狐狸跳过懒狗。”&return 结束重复 --将每一连续行的字体设置为下一种字体(即第1行的字体为字体1,第2行的字体为字体2,等等) 用i从1重复到这些字体的计数 告诉应用程序“Finder”将此字体设置为这些字体中项目i的名称 告诉应用程序“TextEdit”告诉文档1文本的第i段将字体设置为该字体 结束重复

您可以使用一个unix命令:system_profiler。“SPFontsDataType”的数据类型只提供系统配置文件中的字体。xml将以xml形式表示数据

system_profiler -xml SPFontsDataType > ~/Desktop/myfonts.plist

您可以在内存中或文件中捕获此信息,并根据需要对其进行解析。

+1因为尽管看起来很奇怪,我直到现在才听说过
Font Book
:p播种另一个shell命令的完美方式:“mdls/path/to/font”,它将列出所有字体属性。
set l to {"Regular", "Roman", "Book", "Plain", "55 Roman", "R"}
set found to {}
tell application "Font Book"
    repeat with x in typefaces
        if l contains style name of x then set end of found to name of x
    end repeat
end tell
found
system_profiler -xml SPFontsDataType > ~/Desktop/myfonts.plist