node font list
1.0.0
font-listシステムで使用可能なフォントをリストするためのnode.jsパッケージです。
現在のバージョンは、 MacO 、 Windows 、 Linuxをサポートしています。
npm install font-list const fontList = require ( 'font-list' )
fontList . getFonts ( )
. then ( fonts => {
console . log ( fonts )
} )
. catch ( err => {
console . log ( err )
} )またはタイプスクリプトでこのように:
import { getFonts } from 'font-list'
getFonts ( )
. then ( fonts => {
console . log ( fonts )
} )
. catch ( err => {
console . log ( err )
} )返品値fontsは配列です。
[ '"Adobe Arabic"',
'"Adobe Caslon Pro"',
'"Adobe Devanagari"',
'"Adobe Fan Heiti Std"',
'"Adobe Fangsong Std"',
'Arial',
...
]
フォント名にスペースが含まれている場合、名前は二重引用符で包まれます。そうしないと、 '"Adobe Arabic"' 、 'Arial'など、二重引用符はありません。
スペースを含むフォント名を二重引用符で包む必要がない場合は、メソッドgetFontsを呼び出すときに、 disableQuoting SetをTrueに設定してオプションオブジェクトを渡します。
const fontList = require ( 'font-list' )
fontList . getFonts ( { disableQuoting : true } )
. then ( fonts => {
console . log ( fonts )
} )
. catch ( err => {
console . log ( err )
} )