« フォントの詳細情報を取得する(少し手直し) | トップページ | 画像にテキストを描画する »

フォント名を選ぶ


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.6"
use framework "foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application
##デフォルト
set strDefailtsFont to "Osaka-Mono" as text
set appFontManager to refMe's NSFontManager
set appSharedMaanager to appFontManager's sharedFontManager()
set ocidFontListArray to appSharedMaanager's availableFonts()
set numDefaultsFont to (ocidFontListArray's indexOfObject:(strDefailtsFont)) as integer
set listFontList to ocidFontListArray as list
try
  set listResponse to (choose from list listFontList with title "選んでください" with prompt "フォントを選んでください" default items (item numDefaultsFont of listFontList) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if listResponse is false then
return "キャンセルしました"
end if

set strFontName to (item 1 of listResponse)

|

« フォントの詳細情報を取得する(少し手直し) | トップページ | 画像にテキストを描画する »

NSFontManager」カテゴリの記事