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

COLRv1 support #298

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

COLRv1 support #298

wants to merge 22 commits into from

Conversation

simoncozens
Copy link

This is a WIP PR for COLRv1 support. At the moment it should handle the decoding of COLRv1 tables, but this isn't plugged in to the rest of the library. To get that working, we would need to think through how we want to represent paint trees.

Also no tests yet, but they're coming.

@simoncozens
Copy link
Author

simoncozens commented Dec 6, 2022

As of this point, we can render (simple) COLRv1 glyphs on canvas:

const dpi = window.devicePixelRatio;
const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");
canvas.style.width = '200px'
canvas.style.height = '200px'
canvas.getContext('2d').scale(dpi, dpi);
ctx.transform(1.0, 0, 0, -1.0, 0,120); // flip Y direction, 0 in font is baseline, 0 in canvas is top!

let glyph = font.glyphForCodePoint(0x270d);
glyph.render(ctx, 120);

Screenshot 2022-12-06 at 14 08 49

Next step... instantiating variable paints!

@simoncozens
Copy link
Author

Code is done, needs tests.

@simoncozens simoncozens marked this pull request as ready for review June 8, 2023 08:52
@simoncozens
Copy link
Author

This is ready to merge, I think. Here is an example of a Jquery polyfill using fontkit to render COLRv1 fonts on Safari, which is not currently supported natively:

Screenshot 2023-06-08 at 10 38 28

@simoncozens
Copy link
Author

Ping?

Also, the last commit I just added is not technically related to COLRv1; I was going to submit it as a separate PR but it builds on the fact that the DeltaSetIndexMap is moved to variations.js instead of HVAR. This allows for some of the gnarlier tables (ItemVariationStore, DeltaSetIndexMap) to be written back to binary, for example after being edited or subsetted. If it's out of scope I'm happy to drop it.

@Lorp Lorp mentioned this pull request Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant