Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable font (= CFF2) writing #701

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

Conversation

Connum
Copy link
Contributor

@Connum Connum commented Apr 20, 2024

This PR is still a draft & work in progress!

Description

This PR is a follow-up on #699, which implemented reading of different *var tables and rendering of variable fonts. It will implement the writing side as well as some smaller refactoring, and as we always write in CFF format, it made it necessary to implement writing of CFF2 format as well, which is needed for variation data in CFF fonts.

  • Store blend operation deltas
  • Use deltas instead of re-parsing the CharString on transformation
  • write CFF2 format
  • support writing (global) sub routines
  • support sub routines for glyphs that only consist of them
  • refactor cff2 table structure (right now we store indices e.g. in vstore and the actual data in _vstore, which we do for none of the other tables; also sometimes dicts are objects with a single property instead of directly containing the data, which just adds overhead)
  • make CFF2 the default, with a setting to force version 1 (for non-variable fonts or saving a non-variable version of a font)
  • implement a method to create a non-variable version from any variation instance or coords

TODOs for the future

  • Implement an algorithm that finds candidates for (global) sub routines and adds them accordingly

Motivation and Context

Now that we can render variable fonts, with this PR we'll be able to create and save them as well. We can also make use of the reduced data size of CFF2 vs CFF.

How Has This Been Tested?

Made sure that existing tests still pass (or adapted tests to account for the newly to-be-expected data), added new tests.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I did npm run test and all tests passed green (including code styling checks).
  • I have added tests to cover my changes.
  • My change requires a change to the documentation.
  • I have updated the README accordingly.
  • I have read the CONTRIBUTING document.

@Connum Connum added enhancement writing support Anything related to writing support as opposed to parsing or rendering labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement writing support Anything related to writing support as opposed to parsing or rendering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getEnglishName('fontFamily') returns undefined, font.names.macintosh is incomplete
1 participant