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

TTF gets converted to CFF

Open ollimeier opened this issue 2 years ago • 1 comments
trafficstars

Expected Behavior

When loading a TTF font I would expect to have truetype tables in the font object. But in fact, I get CFF data.

Current Behavior

Any TTF will be converted into CFF data, eg. there is no glyf table in 'tables'.

Possible Solution

When loading a TTF -> no changes to the actual data.

Steps to Reproduce (for bugs)

for example:

const font = loadSync('./test/fonts/Roboto-Black.ttf');
font.download('Roboto-Black-test.ttf')

Context

I tried to open a TTF file and change only one value in the OS/2 table and save it again. But when I saved the font, it's messed up totally. Many changes have been made automatically and even outlines have been converted to CFF.

Your Environment

  • Version used: The latest master-branch
  • Font used: eg. ./test/fonts/Roboto-Black.ttf
  • Browser Name and version: Not important.
  • Operating System and version (desktop or mobile): Not important.
  • Link to your project: https://github.com/moontypespace

ollimeier avatar Apr 16 '23 11:04 ollimeier

opentype.js currently only supports writing in CFF format, and even that doesn't support all features yet. I think it's very unlikely the library will ever implement TTF format in writing for a variety of reasons, but of course that's open for discussion and if someone came along with a PR implementing a format switch for reading/storing the data and writing, it wouldn't be rejected. But right now, there are too many other features to tackle.

Connum avatar Jul 31 '23 19:07 Connum