Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Books
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

システムフォントをWeightつきで指定

Posted on 5月 15, 2020 by Takaaki Naganoya

システムフォントを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"

★Click Here to Open This Script 

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"

★Click Here to Open This Script 

More from my site

  • アラートダイアログ上のTable Viewで起動中のアプリケーションを選択 v3cアラートダイアログ上のTable Viewで起動中のアプリケーションを選択 v3c
  • アラートダイアログ上に印刷対象ページ一覧を表示して対象ページを指定アラートダイアログ上に印刷対象ページ一覧を表示して対象ページを指定
  • プログラムで作ったアラートダイアログ上のTextViewをフォーカスするプログラムで作ったアラートダイアログ上のTextViewをフォーカスする
  • システムフォントの名称を取得システムフォントの名称を取得
  • NSFontPanelでフォントを選択NSFontPanelでフォントを選択
  • 相対パスを計算で求める相対パスを計算で求める
(Visited 115 times, 1 visits today)
Posted in Font System | Tagged 10.13savvy 10.14savvy 10.15savvy NSFont | Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular posts

  • macOS 13, Ventura(継続更新)
  • アラートダイアログ上にWebViewで3Dコンテンツを表示(WebGL+three.js)v3
  • UI Browserがgithub上でソース公開され、オープンソースに
  • Xcode 14.2でAppleScript App Templateを復活させる
  • macOS 13 TTS Voice環境に変更
  • 2022年に書いた価値あるAppleScript
  • ChatGPTで文章のベクトル化(Embedding)
  • 新発売:AppleScriptからSiriを呼び出そう!
  • iWork 12.2がリリースされた
  • 従来と異なるmacOS 13の性格?
  • 新発売:CotEditor Scripting Book with AppleScript
  • macOS 13対応アップデート:AppleScript実践的テクニック集(1)GUI Scripting
  • AS関連データの取り扱いを容易にする(はずの)privateDataTypeLib
  • macOS 12.5.1、11.6.8でFinderのselectionでスクリーンショット画像をopenできない問題
  • macOS 13でNSNotFoundバグふたたび
  • ChatGPTでchatに対する応答文を取得
  • 新発売:iWork Scripting Book with AppleScript
  • Finderの隠し命令openVirtualLocationが発見される
  • macOS 13.1アップデートでスクリプトエディタの挙動がようやくまともに
  • あのコン過去ログビューワー(暫定版)

Tags

10.11savvy (1101) 10.12savvy (1242) 10.13savvy (1390) 10.14savvy (586) 10.15savvy (434) 11.0savvy (277) 12.0savvy (185) 13.0savvy (55) CotEditor (60) Finder (47) iTunes (19) Keynote (98) NSAlert (60) NSArray (51) NSBezierPath (18) NSBitmapImageRep (20) NSBundle (20) NSButton (34) NSColor (51) NSDictionary (27) NSFileManager (23) NSFont (18) NSImage (41) NSJSONSerialization (21) NSMutableArray (62) NSMutableDictionary (21) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (117) NSURL (97) NSURLRequest (23) NSUTF8StringEncoding (30) NSView (33) NSWorkspace (20) Numbers (56) Pages (37) Safari (41) Script Editor (20) WKUserContentController (21) WKUserScript (20) WKUserScriptInjectionTimeAtDocumentEnd (18) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • Clipboard
  • Code Sign
  • Color
  • Custom Class
  • dialog
  • drive
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • Hex
  • History
  • How To
  • iCloud
  • Icon
  • Image
  • Input Method
  • Internet
  • iOS App
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Keychain
  • Language
  • Library
  • list
  • Locale
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • rectangle
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • Review
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • selection
  • shell script
  • Shortcuts Workflow
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年10月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org

Forum Posts

  • 人気のトピック
  • 返信がないトピック

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC