opentypejs / opentype.js

Read and write OpenType fonts using JavaScript.
https://opentype.js.org/
MIT License
4.37k stars 467 forks source link

TTF gets converted to CFF #594

Open ollimeier opened 1 year ago

ollimeier commented 1 year ago

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

Connum commented 11 months ago

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.