[NSFontManager]フォントのリストを取得する(基本編)
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #! /usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | #com.cocolog-nifty.quicktimer.icefloe |
004 | # 日本語判定方法がわからないので現状はここまで |
005 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
006 | use AppleScript version "2.8" |
007 | use framework "Foundation" |
008 | use framework "AppKit" |
009 | use scripting additions |
010 | |
011 | property refMe : a reference to current application |
012 | |
013 | set appFontManager to (refMe's NSFontManager's sharedFontManager()) |
014 | #フォント |
015 | set ocidFontArray to appFontManager's availableFonts() |
016 | set numCntFont to ocidFontArray's |count|() |
017 | log "フォント数:" & numCntFont |
018 | #フォントファミリー |
019 | set ocidFontFamiliesArray to appFontManager's availableFontFamilies() |
020 | set numCntFontFamily to ocidFontFamiliesArray's |count|() |
021 | log "フォントファミリー数:" & numCntFontFamily |
022 | |
023 | #ファミリー順に繰り返し |
024 | repeat with itemFontFamily in ocidFontFamiliesArray |
025 | log "フォントファミリー名:" & itemFontFamily |
026 | set ocidFontArray to (appFontManager's availableMembersOfFontFamily:(itemFontFamily)) |
027 | repeat with itemFont in ocidFontArray |
028 | log "POST SCRIPT NAME名:" & (itemFont's objectAtIndex:(0)) |
029 | log "SUB NAME スタイル名:" & (itemFont's objectAtIndex:(1)) |
030 | log "フォントのウェイト 細1<-->太12:" & (itemFont's objectAtIndex:(2)) |
031 | log "フォントの種類:" & (itemFont's objectAtIndex:(3)) |
032 | (* |
033 | log refMe's NSBoldFontMask as integer |
034 | -->(*2*) |
035 | log refMe's NSCompressedFontMask as integer |
036 | -->(*512*) |
037 | log refMe's NSCondensedFontMask as integer |
038 | -->(*64*) |
039 | log refMe's NSExpandedFontMask as integer |
040 | -->(*32*) |
041 | log refMe's NSFixedPitchFontMask as integer |
042 | -->(*1024*) |
043 | log refMe's NSItalicFontMask as integer |
044 | -->(*1*) |
045 | log refMe's NSNarrowFontMask as integer |
046 | -->(*16*) |
047 | log refMe's NSNonStandardCharacterSetFontMask as integer |
048 | -->(*8*) |
049 | log refMe's NSPosterFontMask as integer |
050 | -->(*256*) |
051 | log refMe's NSSmallCapsFontMask as integer |
052 | -->(*128*) |
053 | log refMe's NSUnboldFontMask as integer |
054 | -->(*4*) |
055 | log refMe's NSUnitalicFontMask as integer |
056 | -->(*16777216*) |
057 | *) |
058 | end repeat |
059 | end repeat |
AppleScriptで生成しました |
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #! /usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | #com.cocolog-nifty.quicktimer.icefloe |
004 | # 日本語判定方法がわからないので現状はここまで |
005 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
006 | use AppleScript version "2.8" |
007 | use framework "Foundation" |
008 | use framework "AppKit" |
009 | use scripting additions |
010 | |
011 | property refMe : a reference to current application |
012 | |
013 | set appFontManager to (refMe's NSFontManager's sharedFontManager()) |
014 | |
015 | set listFontMask to {(refMe's NSBoldFontMask), (refMe's NSCompressedFontMask), (refMe's NSCondensedFontMask), (refMe's NSExpandedFontMask), (refMe's NSFixedPitchFontMask), (refMe's NSItalicFontMask), (refMe's NSNarrowFontMask), (refMe's NSNonStandardCharacterSetFontMask), (refMe's NSPosterFontMask), (refMe's NSSmallCapsFontMask), (refMe's NSUnboldFontMask), (refMe's NSUnitalicFontMask)} |
016 | repeat with itemMask in listFontMask |
017 | set ocidFontTraitsArray to (appFontManager's availableFontNamesWithTraits:(itemMask)) |
018 | log ocidFontTraitsArray as list |
019 | end repeat |
AppleScriptで生成しました |
| 固定リンク
« [Font]フォントリスト(サンプル文字入り)でRTFリッチテキストを生成する | トップページ | [NSMutableAttributedString]新規RTFリッチテキストファイルを作成する »
「NSFontManager」カテゴリの記事
- [NSFontManager]フォント名の取得(修正)(2024.12.24)
- [NSFont]フォント名の取得(フォント名=FULLNAME 英語 日本語ローカライズ名 postscript名)(2024.12.11)
- Fontのpostscript名を取得する(訂正)(2024.09.24)
- [NSFontManager]フォントのリストを取得する(基本編)(2024.06.18)
- [font book]フォントライブラリを作成する(2023.06.19)