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

Native font parser #2475

Merged
merged 2 commits into from
Jan 11, 2025
Merged

Native font parser #2475

merged 2 commits into from
Jan 11, 2025

Conversation

chearon
Copy link
Collaborator

@chearon chearon commented Dec 29, 2024

This is the first part needed for the new font stack, which will look like the FontFace-based API the browsers have. FontFace uses a parser for font-family, font-size, etc., so I will need deeper control over the parser.

FontFace will be implemented in C++ and I didn't want to carry over the awkward (and slow) switching between JS and C++. So here it is. I used Claude to generate initial classes and busy work, but it's been heavily examined and heavily modified.

Caching aside, this is 3x faster in the benchmarks, which use random names to bypass the cache, and still a full 2x as fast when the JS version has a cached value. Those results were a bit inconsistent, so I'm not sure how much I trust them, but I expect this parser to have a stable performance profile nonetheless, so I'm not going to add any caching.

It's also far more correct than what we had!

@chearon chearon mentioned this pull request Dec 29, 2024
4 tasks
This is the first part needed for the new font stack, which will
look like the FontFace-based API the browsers have. FontFace uses
a parser for font-family, font-size, etc., so I will need deeper
control over the parser.

FontFace will be implemented in C++ and I didn't want to carry
over the awkward (and slow) switching between JS and C++. So here
it is. I used Claude to generate initial classes and busy work,
but it's been heavily examined and heavily modified.

Caching aside, this is 3x faster in the benchmarks, which use
random names to bypass the cache, and still a full 2x as fast when
the JS version has a cached value. Those results were a bit
inconsistent, so I'm not sure how much I trust them, but I expect
this parser to have a stable performance profile nonetheless, so
I'm not going to add any caching.

It's also far more correct than what we had!
@chearon chearon force-pushed the ch/parse-font-native branch from be42c27 to a7f5553 Compare January 11, 2025 16:49
@chearon chearon merged commit 728e76c into master Jan 11, 2025
26 checks passed
@chearon chearon deleted the ch/parse-font-native branch January 11, 2025 20:11
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.

1 participant