Adobe Illustrator-自动将TrueType字体更改为OpenType版本



我正试图找出一个脚本(无论是javascript还是AppleScript(或任何可以将多个.eps文件中的truetype字体更改为这些字体的opentype(otf(版本的东西,而无需在Illustrator中为每个文件手动执行此操作。

这可能是不可能的,但任何建议,即使他们没有做到这一点,都是受欢迎的。

这可以使用以下AppleScript实现,但您需要定义字体映射列表。

1.示例AppleScript

set fontMap to {{"Courier", "CourierPSStd"}, {"Baskerville", "BaskervilleMTStd-Regular"}, {"GillSans", "GillSansStd"}}
tell application "Finder"
set chosenFolder to choose folder with prompt "Choose a folder which contains the EPS files to process"
set epsFileList to files of entire contents of folder chosenFolder whose name extension is "eps" and creator type is "ART5" as list
my replaceFonts(epsFileList, fontMap)
end tell
on replaceFonts(epsFileList, fontMap)
tell application "Adobe Illustrator"
repeat with thisEpsFile in epsFileList
set user interaction level to never interact
open thisEpsFile as alias without dialogs
tell document 1
repeat with thisMap in fontMap
try
set text font of (characters of stories whose properties contains {text font:text font (item 1 of thisMap)}) to text font (item 2 of thisMap) of application "Adobe Illustrator"
end try
end repeat
close saving yes
end tell
set user interaction level to interact with all
end repeat
end tell
end replaceFonts

2.脚本的作用是什么

  1. 它会提示用户选择一个文件夹,该文件夹包含要批量处理的.eps文件
  2. 在所选文件夹中找到的每个.eps文件(包括子文件夹中的文件(都会在Illustrator中重复打开
  3. 打开每个文件后,它会找到给定字体的所有实例,并将其替换为另一个给定字体
  4. 每个文件都被保存,然后在处理下一个文件之前关闭

3.运行脚本之前需要做什么

不幸的是,Illustrator无法知道哪种TrueType字体应该替换为哪种等效的OpenType字体。因此,您需要自己定义哪种字体应该映射/替换为哪种字体。要做到这一点,你需要在当前代码的第一行中定义每个字体配对:

set fontMap to {{"Courier", "CourierPSStd"}, {"Baskerville", "BaskervilleMTStd-Regular"}, {"GillSans", "GillSansStd"}}

这行代码(二维数组(,给定其当前值,通知脚本:

  • "CourierPSStd"替换"Courier"的任何实例
  • "Baskerville"的任何实例替换为"BaskervilleMTStd-Regular"
  • "GillSans"的任何实例替换为"GillSansStd"

提示:如何找到正确的字体名称来创建fontMap数组

我建议您启动Illustrator并从AppleScript编辑器运行这个非常简单的脚本:

tell application "Adobe Illustrator"
set fontNames to name of every text font
end tell

如果您查看AppleScript编辑器中的Result面板,您将看到计算机上每个可用字体的名称列表。


4.注意事项

第5行的代码行,它读取;

set epsFileList to files of entire contents of folder chosenFolder whose name extension is "eps" and creator type is "ART5" as list

从所选择的文件夹中获得要处理的CCD_ 10文件的列表。目前,发现的任何具有"eps"name extension"ART5"creator type的文件("ART5"意味着它是由Illustrator创建的(都将包括在批处理过程中。您可能需要省略以下部分:

and creator type is "ART5"

如果您的.eps文件不是由Illustrator创建的。但是,脚本可能会尝试处理任何位图.eps文件(例如在PhotoShop中创建的文件(。


注意:此脚本当前保存对文件所做的任何更改,因此如果您没有定义适当的fontMap数组,它可能会非常具有破坏性。我建议您在测试时在.eps文件的副本上运行此操作,并可能省略读取close saving yes的代码行,直到您确信fontMap产生了所需的结果

最新更新