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

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

Native font parser #2475

wants to merge 2 commits into from

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!

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
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