opentype.js icon indicating copy to clipboard operation
opentype.js copied to clipboard

TrueType Collection file. Error: Unsupported OpenType signature ttcf

Open punksta opened this issue 5 years ago • 4 comments

I am trying to open font file with multiple styles inside.

Expected Behavior

font collection file is handled, opentype.js finds multiple fonts.

Current Behavior

image

Possible Solution

I have know idea to be honest :)

Steps to Reproduce (for bugs)

compile multiple ttf fonts into one file using this guide https://graphicdesign.stackexchange.com/a/104892/137343

Context

I want to get supported styles from font file

Your Environment

  • Version used: web preview
  • Font used: roboto from google fonts
  • Browser Name and version: latest stable firefox and chrome
  • Operating System and version (desktop or mobile): mac, ubuntu 19.04
  • Link to your project:

punksta avatar Apr 24 '19 09:04 punksta

https://mega.nz/#!OINDmA7I!KiPqAMqfXSp-QBLzUWjcsbasr4vjS8pObOnE9oqjdZw the file I was using

punksta avatar Apr 24 '19 09:04 punksta

https://www.npmjs.com/package/fontkit#font-collection-objects found this.

punksta avatar Apr 24 '19 09:04 punksta

@punksta Indeed this is not yet supported and if anybody wants to contribute my guess is that this could be helpful:

  • Adding a postscriptName to the open method https://github.com/foliojs/fontkit/blob/436bd5e939e69dcf1e62ccb384cd8b7d07d263de/src/base.js#L19
  • Iterating on the collection to find one that matches the postscriptName https://github.com/foliojs/fontkit/blob/e2ff84e69f83272a0f05179d537a86a462aea299/src/TrueTypeCollection.js#L34
  • Tests: https://github.com/foliojs/fontkit/blob/e2ff84e69f83272a0f05179d537a86a462aea299/test/index.js#L59

The current workaround would be to find a .ttf, .otf or woff version of your font, or to unpackage the font collection to get all the .ttf

Jolg42 avatar Apr 24 '19 12:04 Jolg42

I ended up using fontkit. It does not support getting ttf files from font collection, but it can return list of font with names and other data. This is exactly that I needed.

punksta avatar Apr 24 '19 20:04 punksta