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

Implement variable font rendering (gvar, avar, hvar, cvar) #699

Merged
merged 65 commits into from
Apr 20, 2024

Conversation

Connum
Copy link
Contributor

@Connum Connum commented Apr 11, 2024

This PR implements rendering of variable fonts.

Description

  • Docs (index and Glyph Inspector): Selection of predefined instances from the fvar table, all axes available as range sliders, render variations instantly. Some other improvements.
  • supports gvar point transformation
  • supports avar point transformation
  • supports hvar advanceWidth and leftSideBearing transformation
  • support for variation coordinates in the rendering options
  • able to set default variation for the whole font
  • works with hinting and cvar table
  • adapted test render script to have less tests fail due to minor path differences

TODOs before this is ready for review:

  • look into the bug that the fontkit implementation has as well
  • support advanceWidth transform
  • see if we can easily support CFF2 blend transforms
  • see if we can easily support hvar transform
  • see if it makes sense to support cvar as well
  • Check toSVG results
  • run unicode test suite
  • try to fix more unicode tests
  • Add gvar tests, including those from the unicode test suite
  • Add avar tests
  • Add hvar tests
  • Add cvar glyph tests
  • Add cvar tests
  • Update API documentation in README

TODOs for future PRs:

  • add cvar writing capability
  • add gvar writing capability
  • add HVAR writing support
  • add higher level methods for working more comfortably with variation data (like implemented color glyph layers and palettes)

Motivation and Context

Finally, after supporting parsing of the required tables, we can also render glyph variations.

How Has This Been Tested?

Visual testing, comparing coordinates with other implementations, added tests.

Screenshots (if appropriate):

image
image

The tests in the unicode test suite regarding the supported tables look fine, only a few are failing due to minor rounding differences. Several unrelated tests have been fixed along the way.
passing: 212, failing: 539) as opposed to passing: 37, failing: 708 with 1.3.4.
image
image
image
image
image
image
image

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 marked this pull request as ready for review April 15, 2024 21:23
@Connum Connum requested review from yne and ILOVEPIE April 15, 2024 21:23
@Connum
Copy link
Contributor Author

Connum commented Apr 20, 2024

pinging @yne @ILOVEPIE

@Connum Connum mentioned this pull request Apr 20, 2024
16 tasks
Copy link
Contributor

@yne yne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressiv work ! @Connum

Can't wait to play with this new API

Shall we squash before merging ?

@Connum Connum merged commit 262adb2 into master Apr 20, 2024
1 check passed
@Connum Connum deleted the font-variation branch April 20, 2024 17:12
@ILOVEPIE
Copy link
Contributor

I'd have to do a full look through the code, but from what I can see it looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants