
在 Sketch 68 之後,增加了讓人激動的新功能“嵌入字體”。
此功能有喜也有愁,好的地方分享 Sketch 文件不需要再顧慮字體問題,愁的地方每一個字體都需要點擊同意授權真的很煩惱。
在 macOS 中,很早很早的版本就已經內置了 AppleScript 的腳本語言。透過 AppleScript 可輕鬆編寫可以操作批量任務的事情。
因此,我編寫了一個 AppleScript 腳本來批量點擊這些對話框。
set theCount to 0
--set theText to "Not Embedded"
set theText to "Embed In Document"
repeat while true
set theCount to theCount + 1
log theCount
tell application "System Events"
tell process "Sketch"
tell UI element 1 of row theCount of table 1 of scroll area 1 of sheet 1 of window 1
try
tell pop up button 1
click
click menu item theText of menu 1
delay 0.1
try
tell application "System Events"
tell process "Sketch"
click checkbox "I agree to the terms and policies" of sheet 1 of sheet 1 of window 1
click button "proceed" of sheet 1 of sheet 1 of window 1
end tell
end tell
end try
end tell
on error
display notification theCount with title "Sketch Fonts Loop Embed in Document" subtitle "All is Done"
log "exit"
exit repeat
end try
end tell
end tell
end tell
end repeat
我們只需要把上述的代碼複製到【程式碼編寫程式】再點擊一下運行按鈕,即可開始輕鬆的自動化完成了。