-
Notifications
You must be signed in to change notification settings - Fork 501
COLR/CPAL color glyph rendering #695
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… next to range sliders
… present in newly loaded font
8 tasks
yne
reviewed
Apr 6, 2024
yne
reviewed
Apr 6, 2024
yne
reviewed
Apr 6, 2024
yne
reviewed
Apr 6, 2024
yne
reviewed
Apr 6, 2024
yne
reviewed
Apr 6, 2024
yne
reviewed
Apr 6, 2024
yne
reviewed
Apr 6, 2024
…um/opentype.js-next into feature/colr-cpal-rendering
yne
approved these changes
Apr 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
editing
Issues related to editing of glyphs, regarded as out of scope for now
enhancement
font features
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
LayerManager
object inFont.layers
and aPaletteManager
inFont.palettes
util.js
path.close()
if a path is rendered without a stroke, as filling a path will automatically close the path anyway, resulting in an unnecessary calculation.path.close()
was a big factor for long computation times when analyzing performance using the browser dev tools.Note: The more complex the supported features become (color glyphs, in the future hopefully font variation support), the worse the drawing performance gets. We will definitely have to implement some optimizations like caching in the future, or maybe even going full-async, in order to reduce computations and therefore increasing performance.
testutil.js
createMockObject()
: creates a mock object for any browser element or API that we couldn't test in node otherwise (e.g. canvas contexts). The logs array includes all the calls and property accesses on the object, then it can be tested if the methods and parameters match expected operations.enableMockCanvas()
enables testing canvas functionality that would normally only work in browser context (creating a mock canvas element, CSS color name conversion)Motivation and Context
#490 added parsing and writing support for both tables, but actually getting the paths and colors for a color glyph and drawing it was not implemented. Manipulating the layers and palettes is quite complex, and developers using opentype.js would all have had to implement similar functionality in order to make use of the data. With this PR it works out-of-the-box.
How Has This Been Tested?
I added fairly extensive tests that should cover everything.
Screenshots (if appropriate):
Types of changes
Checklist:
npm run test
and all tests passed green (including code styling checks).