20260325

クレジットカードの番号フォントSpendcardium macOS標準搭載(Farrington 7B互換)


FontServices.frameworkの主要フォントをフォントブックのライブラリ登録します

ダウンロードはこちらから
NOTE記事一覧ですnote.com

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

FontServicesのフォントライブラリ追加v1.1.scpt
ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(*
004FontServices.framework(UI等でOSが使うフォント)の中で
005普通にフォントとして機能しそうなフォントだけ
006ライブラリを作って登録します
007
008
009v1 初回作成
010v1.1 macOS26.4のフォントで再調査
011
012
013com.cocolog-nifty.quicktimer.icefloe *)
014----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
015use AppleScript version "2.8"
016use framework "Foundation"
017use framework "UniformTypeIdentifiers"
018use framework "AppKit"
019use scripting additions
020
021property refMe : a reference to current application
022
023##############################
024#フォントブックを終了
025set strBundleID to ("com.apple.FontBook") as text
026try
027   tell application id strBundleID to quit
028on error strErrMsg number numErrNo
029   set strBundleID to (strBundleID) as text
030   set appRunningAppArray to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
031   repeat with itemRunApp in appRunningAppArray
032      set boolDone to itemRunApp's terminate()
033      if boolDone is false then
034         set boolDone to itemRunApp's forceTerminate()
035      end if
036   end repeat
037   delay 1
038end try
039##############################
040set listFontFilePath to {"/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/AsphaltMedium.otf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/BalegaRegular.otf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/BebasNeue.otf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/FaktSlabStencilPro-medium.otf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/JournalSansInline.otf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/SchemeBold.otf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/TheHandSerif-semibold.otf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Blackmoor LET Fonts.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Blair Medium.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Bodoni SvtyTwo SC Book.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Bordeaux Roman Bold LET Fonts.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Braganza.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Capitals.ttf", "/System/Library/PrivateFrameworks/Slideshows.framework/Versions/A/Resources/Content/Fonts/Coolvetica.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Hopper Script.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Jazz LET Fonts.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Mona Lisa Solid ITC TT.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/PortagoITC TT.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Princetown LET Fonts.ttf", "/System/Library/PrivateFrameworks/Slideshows.framework/Versions/A/Resources/Content/Fonts/Proxima Nova Bold.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Santa Fe LET Fonts.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/SchoolHouse Cursive B.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/SchoolHouse Printed A.ttf", "/System/Library/PrivateFrameworks/PassKitUIFoundation.framework/Versions/A/Resources/SourceSans3-Italic.ttf", "/System/Library/PrivateFrameworks/CoreRecognition.framework/Versions/A/Resources/Fonts/Spendcardium.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Synchro LET Fonts.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Type Embellishments One LET.ttf", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/BankGothic.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Bodoni SvtyTwo OS.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Bodoni SvtyTwo.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/BookAntiqua.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/BookmanOldStyle.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Carlito.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/CenturyGothic.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/CenturySchoolbook.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/DearJoe.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Druk.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/ForgottenFuturist.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Garamond.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/Stone Sans.ttc", "/System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport/TwentiethCentury.ttc"} as list
041
042set ocidFontsPathArray to refMe's NSMutableArray's alloc()'s init()
043#
044set ocidWhiteUTI to refMe's UTType's typeWithIdentifier:("public.font")
045set ocidWhiteSupUTI to ocidWhiteUTI's supertypes()
046
047repeat with itemFontFilePath in listFontFilePath
048   set strFilePath to itemFontFilePath
049   set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
050   set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
051   set ocidFilePathURL to (refMe's NSURL's fileURLWithPath:(ocidFilePath) isDirectory:(false))
052   (ocidFontsPathArray's addObject:(ocidFilePathURL))
053end repeat
054
055
056
057##############################
058#FontCollectionsのフォルダパス
059set appFileManager to refMe's NSFileManager's defaultManager()
060set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
061set ocidUserLibraryPath to ocidUserLibraryPathArray's firstObject()
062set ocidSaveFilePathURL to ocidUserLibraryPath's URLByAppendingPathComponent:("FontCollections/FontServices.library") isDirectory:(false)
063set ocidFileName to ocidSaveFilePathURL's lastPathComponent()
064set ocidBaseFileName to ocidFileName's stringByDeletingPathExtension()
065
066##############################
067# PLIST処理
068#PLISTのデータになるDict
069set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s init()
070
071#disabled
072set ocidFalse to (refMe's NSNumber's numberWithBool:false)
073ocidPlistDict's setValue:(ocidFalse) forKey:("disabled")
074#name
075ocidPlistDict's setValue:(ocidBaseFileName) forKey:("name")
076#reference
077set ocidReference to refMe's NSNumber's numberWithInteger:(1)
078ocidPlistDict's setValue:(ocidReference) forKey:("reference")
079#date
080set ocidDate to (refMe's NSDate's |date|())
081set ocidFormatter to refMe's NSDateFormatter's alloc()'s init()
082ocidFormatter's setDateFormat:("yyyy-MM-dd'T'HH:mm:ss'Z'")
083ocidFormatter's setTimeZone:(refMe's NSTimeZone's timeZoneWithAbbreviation:("UTC"))
084set ocidSetDate to ocidFormatter's stringFromDate:(ocidDate)
085-->string形式でセットするのでsetValueで
086ocidPlistDict's setValue:(ocidSetDate) forKey:("date")
087#version
088ocidFormatter's setDateFormat:("yyyyMMdd")
089set ocidversion to ocidFormatter's stringFromDate:(ocidDate)
090ocidPlistDict's setValue:(ocidversion) forKey:("version")
091
092##############################
093#containerURLs
094set ocidContainerURLsArray to refMe's NSMutableArray's alloc()'s init()
095repeat with itemFontURL in ocidFontsPathArray
096   set ocidItemFontPath to itemFontURL's absoluteString()
097   (ocidContainerURLsArray's addObject:(ocidItemFontPath))
098end repeat
099ocidPlistDict's setObject:(ocidContainerURLsArray) forKey:("containerURLs")
100##############################
101#bookmarks
102set ocidBookmarks to refMe's NSMutableDictionary's alloc()'s init()
103ocidPlistDict's setObject:(ocidBookmarks) forKey:("bookmarks")
104
105#####################
106#urlAddedDates
107set ocidUrlAddedDatesDict to refMe's NSMutableDictionary's alloc()'s init()
108###フォントのURLを追加(absoluteString形式)
109repeat with itemFontPathArray in ocidFontsPathArray
110   set strPath to (itemFontPathArray's |path|())
111   (ocidUrlAddedDatesDict's setValue:(ocidSetDate) forKey:(strPath))
112end repeat
113ocidPlistDict's setObject:(ocidUrlAddedDatesDict) forKey:("urlAddedDates")
114
115######################
116#XML形式
117set ocidXmlplist to (refMe's NSPropertyListXMLFormat_v1_0)
118#書き込み用にXMLに変換
119set listResponse to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidPlistDict) format:(ocidXmlplist) options:0 |error|:(reference)
120set ocidPlistEditData to (first item of listResponse)
121#NSDATA
122set ocidOption to (refMe's NSDataWritingAtomic)
123set listDone to ocidPlistEditData's writeToURL:(ocidSaveFilePathURL) options:(ocidOption) |error|:(reference)
124
125#フォントブックを起動
126tell application id "com.apple.FontBook"
127   launch
128end tell
129tell application id "com.apple.FontBook"
130   activate
131end tell
132
133return (first item of listDone)
AppleScriptで生成しました