AppleScript名:インストールされているフォントをdisplay nameからキーワード検索 v3 |
— Created 2017-11-01 by Takaaki Naganoya — Modified 2017-11-02 by Shane Stanley use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" –http://piyocast.com/as/archives/4948 property NSFontManager : a reference to current application’s NSFontManager property NSFont : a reference to current application’s NSFont property NSPredicate : a reference to current application’s NSPredicate set fRes to getEveryFontContainsAQueryStr("Helvetica") of me –> {"Helvetica", "Helvetica-Bold", "Helvetica-BoldOblique", "Helvetica-Light", "Helvetica-LightOblique", "Helvetica-Oblique", "HelveticaNeue", "HelveticaNeue-Bold", "HelveticaNeue-BoldItalic", "HelveticaNeue-CondensedBlack", "HelveticaNeue-CondensedBold", "HelveticaNeue-Italic", "HelveticaNeue-Light", "HelveticaNeue-LightItalic", "HelveticaNeue-Medium", "HelveticaNeue-MediumItalic", "HelveticaNeue-Thin", "HelveticaNeue-ThinItalic", "HelveticaNeue-UltraLight", "HelveticaNeue-UltraLightItalic"} set fRes to getEveryFontContainsAQueryStr("ことり") of me –> {"TheLittleBirdFONT", "kotorimojiFONT-TT"} on getEveryFontContainsAQueryStr(queryName as string) set hitFontList to {} set aFontList to NSFontManager’s sharedFontManager()’s availableFonts() — filter out hidden fonts set thePred to NSPredicate’s predicateWithFormat:"NOT SELF BEGINSWITH ’.’" set aFontList to aFontList’s filteredArrayUsingPredicate:thePred repeat with fontName in aFontList set aFont to (NSFont’s fontWithName:fontName |size|:16) set aDispFontName to (aFont’s displayName()) as string if aDispFontName contains queryName then set end of hitFontList to (fontName as text) end if end repeat return hitFontList end getEveryFontContainsAQueryStr |
More from my site
(Visited 73 times, 1 visits today)