システムフォントをWeightつきで指定するAppleScriptです。
NSFontまわりの、フォント名を具体的に文字列で指定「しない」フォントの指定方法を、(必要があったので)いろいろ調べてみました。
ここに紹介したサンプルでは、System FontをWeightおよびSize指定して取得していますが、本当にやりたいのは言語(英語、日本語など)とセリフつき(Timesなど)サンセリフ(Helveticaなど)、Handwritingフォントかなどの属性情報を指定すると、なんとなくフォントを特定してくれる処理で、とてもOS内にありそうな気もするのですが、まだ見つけられておりません。
AppleScript名:システムフォントをWeightつきで指定.scptd |
— – Created by: Takaaki Naganoya – Created on: 2020/05/14 — – Copyright © 2020 Piyomaru Software, All Rights Reserved — use AppleScript version "2.4" — Yosemite (10.10) or later use framework "Foundation" use framework "AppKit" use scripting additions set aFont1 to current application’s NSFont’s systemFontOfSize:48 weight:(current application’s NSFontWeightRegular) —> (NSFont) ".AppleSystemUIFont 48.00 pt. P [] (0x60000154c060) fobj=0x7f8bb176bfc0, spc=10.20" set aFont1Name to aFont1’s fontName() as string –> ".AppleSystemUIFont" set aFont2 to current application’s NSFont’s systemFontOfSize:48 weight:(current application’s NSFontWeightUltraLight) –> (NSFont) ".AppleSystemUIFontUltraLight 48.00 pt. P [] (0x6000012d42a0) fobj=0x7f8bb8925090, spc=10.10" set aFont2Name to aFont2’s fontName() as string –> ".AppleSystemUIFontUltraLight" set aFont3 to current application’s NSFont’s systemFontOfSize:48 weight:(current application’s NSFontWeightThin) –> (NSFont) ".AppleSystemUIFontThin 48.00 pt. P [] (0x6000013fd350) fobj=0x7f8bb3ba1140, spc=10.12" set aFont3Name to aFont3’s fontName() as string –> ".AppleSystemUIFontThin" set aFont4 to current application’s NSFont’s systemFontOfSize:48 weight:(current application’s NSFontWeightLight) –> (NSFont) ".AppleSystemUIFontLight 48.00 pt. P [] (0x6000013fd410) fobj=0x7f8bb3bbf890, spc=10.17" set aFont4Name to aFont4’s fontName() as string –> ".AppleSystemUIFontLight" set aFont5 to current application’s NSFont’s systemFontOfSize:48 weight:(current application’s NSFontWeightMedium) –> (NSFont) ".AppleSystemUIFontMedium 48.00 pt. P [] (0x60000151c8a0) fobj=0x7f8bb79289e0, spc=10.08" set aFont5Name to aFont5’s fontName() as string –> ".AppleSystemUIFontMedium" set aFont6 to current application’s NSFont’s systemFontOfSize:48 weight:(current application’s NSFontWeightSemibold) –> (NSFont) ".AppleSystemUIFontDemi 48.00 pt. P [] (0x6000013fd710) fobj=0x7f8bb69ef060, spc=9.96" set aFont6Name to aFont6’s fontName() as string –> ".AppleSystemUIFontDemi" set aFont7 to current application’s NSFont’s systemFontOfSize:48 weight:(current application’s NSFontWeightBold) –> (NSFont) ".AppleSystemUIFontBold 48.00 pt. P [] (0x600000bfa430) fobj=0x7f8bb3b55630, spc=9.84" set aFont7Name to aFont7’s fontName() as string –> ".AppleSystemUIFontBold" set aFont8 to current application’s NSFont’s systemFontOfSize:48 weight:(current application’s NSFontWeightHeavy) –> (NSFont) ".AppleSystemUIFontHeavy 48.00 pt. P [] (0x600000898a50) fobj=0x7f8bb3b79730, spc=9.66" set aFont8Name to aFont8’s fontName() as string –> ".AppleSystemUIFontHeavy" set aFont9 to current application’s NSFont’s systemFontOfSize:48 weight:(current application’s NSFontWeightBlack) –> (NSFont) ".AppleSystemUIFontBlack 48.00 pt. P [] (0x6000015a57a0) fobj=0x7f8bb14cb330, spc=9.49" set aFont9Name to aFont9’s fontName() as string –> ".AppleSystemUIFontBlack" |
AppleScript名:システムフォントをWeightつきで指定(monospacedDigitSystemFont).scptd |
— – Created by: Takaaki Naganoya – Created on: 2020/05/14 — – Copyright © 2020 Piyomaru Software, All Rights Reserved — use AppleScript version "2.4" — Yosemite (10.10) or later use framework "Foundation" use framework "AppKit" use scripting additions set aFont1 to current application’s NSFont’s monospacedDigitSystemFontOfSize:16 weight:(current application’s NSFontWeightRegular) —> (NSFont) ".SFNSText 16.00 pt. P [] (0x600001557d80) fobj=0x7f8bb7e011b0, spc=4.20" set aFont1Name to aFont1’s fontName() as string –> ".SFNSText" set aFont2 to current application’s NSFont’s monospacedDigitSystemFontOfSize:16 weight:(current application’s NSFontWeightUltraLight) –> (NSFont) ".SFNSText-Light 16.00 pt. P [] (0x6000015e08d0) fobj=0x7f8bb8914700, spc=4.02" set aFont2Name to aFont2’s fontName() as string –> ".SFNSText-Light" set aFont3 to current application’s NSFont’s monospacedDigitSystemFontOfSize:16 weight:(current application’s NSFontWeightThin) –> (NSFont) ".SFNSText-Light 16.00 pt. P [] (0x600000b789f0) fobj=0x7f8bb697f020, spc=4.02" set aFont3Name to aFont3’s fontName() as string –> ".SFNSText-Light" set aFont4 to current application’s NSFont’s monospacedDigitSystemFontOfSize:16 weight:(current application’s NSFontWeightLight) –> (NSFont) ".SFNSText-Light 16.00 pt. P [] (0x6000015a3c90) fobj=0x7f8bb88c2130, spc=4.02" set aFont4Name to aFont4’s fontName() as string –> ".SFNSText-Light" set aFont5 to current application’s NSFont’s monospacedDigitSystemFontOfSize:16 weight:(current application’s NSFontWeightMedium) –> (NSFont) ".SFNSText-Medium 16.00 pt. P [] (0x6000014667f0) fobj=0x7f8bb891bdd0, spc=4.06" set aFont5Name to aFont5’s fontName() as string –> ".SFNSText-Medium" set aFont6 to current application’s NSFont’s monospacedDigitSystemFontOfSize:16 weight:(current application’s NSFontWeightSemibold) –> (NSFont) ".SFNSText-Semibold 16.00 pt. P [] (0x6000014b7120) fobj=0x7f8bb8866210, spc=3.95" set aFont6Name to aFont6’s fontName() as string –> ".SFNSText-Semibold" set aFont7 to current application’s NSFont’s monospacedDigitSystemFontOfSize:16 weight:(current application’s NSFontWeightBold) –> (NSFont) ".SFNSText-Bold 16.00 pt. P [] (0x600001412dc0) fobj=0x7f8bb8920310, spc=3.81" set aFont7Name to aFont7’s fontName() as string –> ".SFNSText-Bold" set aFont8 to current application’s NSFont’s monospacedDigitSystemFontOfSize:16 weight:(current application’s NSFontWeightHeavy) –> (NSFont) ".SFNSText-Heavy 16.00 pt. P [] (0x600001443720) fobj=0x7f8bb6cea5f0, spc=3.61" set aFont8Name to aFont8’s fontName() as string –> ".SFNSText-Heavy" set aFont9 to current application’s NSFont’s monospacedDigitSystemFontOfSize:16 weight:(current application’s NSFontWeightBlack) –> (NSFont) ".SFNSText-Heavy 16.00 pt. P [] (0x60000145b5d0) fobj=0x7f8bb6996ff0, spc=3.61" set aFont9Name to aFont9’s fontName() as string –> ".SFNSText-Heavy" |