foliojs / font-manager

A C++ module for Node.js providing access to the system font catalog.
MIT License
295 stars 100 forks source link

Pull fonts from custom directory #18

Open swampthang opened 7 years ago

swampthang commented 7 years ago

Great library!

I'm wondering if there is a way to pull fonts from a custom directory. I'm working in an Electron app and have some fonts built in to the app. I like being able to get the metadata and the search feature in your library.

devongovett commented 7 years ago

Currently this module is just for looking up system fonts. I'd like to eventually add support for registering your own fonts.

swampthang commented 7 years ago

Thanks for the reply. That would really be awesome. What's the best way to get metadata from a font file? Like a .ttf or .otf, etc

I'd love to be able to create some nice objects like you have:

{
  family: "Cambria"
  italic: true
  monospace: false
  path: "/Library/Fonts/Microsoft/Cambria Bold Italic.ttf"
  postscriptName: "Cambria-BoldItalic"
  style: "Bold Italic"
  weight: 700
  width: 5
}

Surely there's a way to do that in the meantime, huh?

devongovett commented 7 years ago

That info can be extracted using fontkit.

swampthang commented 7 years ago

Ahh, ok. The README didn't list all the items you include in your font object. I guess they're buried in there somewhere. Will check that out. Thanks!

swampthang commented 7 years ago

Is there any way to only get fonts from the user's font directory? Getting all available fonts is way too much for this app. I didn't realize I had a few thousand.