« [Font]font collection | トップページ | [apachectl]自分用ローカル環境用 »

[Fonts]コレクションにフォントを追加する

add TypeFace to font collection が1フォント約2秒かかるので
平気で1時間とかかかる… 実用には向かない、高速化できれば良いだが方法が見当たらない…泣


ダウンロード - add20to20font20collection.scpt.zip


#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


###############起動を待つ(FontBookの提携必須)
tell application "Font Book" to launch
repeat
try
tell application "Font Book"
activate
properties
end tell
exit repeat
on error
delay 0.5
end try
end repeat
########フォントライブラリの一覧を取得
tell application "Font Book"
properties
set listFontCollections to name of every font collection as list
end tell
####################コレクション作成
set strFontCollectionsName to "100:Thin" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "200:Extra Light" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "300:Light" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "400:Regular" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "500:Medium" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "600:Demi Bold" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "700:Bold" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "800:Extra Bold" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "900:Heavy" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "950:Extra Black" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "Oblique" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################コレクション作成
set strFontCollectionsName to "Italic" as text
set boolSameCollections to 0
repeat with objFontCollections in listFontCollections
set strFontCollections to objFontCollections as text
if strFontCollections is strFontCollectionsName then
set boolSameCollections to 1
end if
end repeat
if boolSameCollections is 0 then
tell application "Font Book"
make new font collection with properties {name:strFontCollectionsName}
end tell
end if
####################################################
####################################################

tell application "Font Book"
tell font domain "User"
set listTypeFace to every typeface
end tell
end tell


tell application "Font Book"
tell font domain "User"
set listStyleName to style name of every typeface
end tell
end tell


set numRepeatCnt to 1
set numCntTypeFace to count of listTypeFace

repeat numCntTypeFace times
tell application "Font Book"
set objTypeFace to item numRepeatCnt of listTypeFace
set objStyleName to item numRepeatCnt of listStyleName

if objStyleName contains "Oblique" then
try
add objTypeFace to font collection "Oblique"
end try
end if
if objStyleName contains "Italic" then
try
add objTypeFace to font collection "Italic"
end try
end if
###################################################
if objStyleName contains "Ultra Light" then
try
add objTypeFace to font collection "100:Thin"
end try
end if
if objStyleName contains "Thin" then
try
add objTypeFace to font collection "100:Thin"
end try
end if
if objStyleName contains "Extra Light" then
try
add objTypeFace to font collection "200:Extra Light"
end try
end if
if objStyleName is "Light" then
try
add objTypeFace to font collection "300:Light"
end try
end if
if objStyleName contains "Regular" then
try
add objTypeFace to font collection "400:Regular"
end try
end if
if objStyleName contains "Medium" then
try
add objTypeFace to font collection "500:Medium"
end try
end if
if objStyleName contains "Demi Bold" then
try
add objTypeFace to font collection "600:Demi Bold"
end try
end if
if objStyleName is "Bold" then
try
add objTypeFace to font collection "700:Bold"
end try
end if
if objStyleName contains "Extra Bold" then
try
add objTypeFace to font collection "800:Extra Bold"
end try
end if
if objStyleName contains "Heavy" then
try
add objTypeFace to font collection "900:Heavy"
end try
end if
###################################################
if objStyleName contains "W0" then
try
add objTypeFace to font collection "100:Thin"
end try
end if
if objStyleName contains "W1" then
try
add objTypeFace to font collection "100:Thin"
end try
end if
if objStyleName contains "W2" then
try
add objTypeFace to font collection "200:Extra Light"
end try
end if
if objStyleName contains "W3" then
try
add objTypeFace to font collection "300:Light"
end try
end if
if objStyleName contains "W4" then
try
add objTypeFace to font collection "400:Regular"
end try
end if
if objStyleName contains "W5" then
try
add objTypeFace to font collection "500:Medium"
end try
end if
if objStyleName contains "W6" then
try
add objTypeFace to font collection "600:Demi Bold"
end try
end if
if objStyleName contains "W7" then
try
add objTypeFace to font collection "700:Bold"
end try
end if
if objStyleName contains "W8" then
try
add objTypeFace to font collection "800:Extra Bold"
end try
end if
if objStyleName contains "W9" then
try
add objTypeFace to font collection "900:Heavy"
end try
end if
###################################################
set numRepeatCnt to numRepeatCnt + 1
end tell
end repeat

|

« [Font]font collection | トップページ | [apachectl]自分用ローカル環境用 »

Fonts」カテゴリの記事