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

improve multi-family output in font desc resolver #2062

Merged
merged 1 commit into from Jun 24, 2022
Merged

Conversation

chearon
Copy link
Collaborator

@chearon chearon commented Jun 24, 2022

This bug can be understood without considering the changes from #1987. When the user adds multiple TTFs and assigns them the same family name, we send the system families from the TTFs in a comma separated list, but we weren't correctly ordering that system-family list by the best matches on the user-description side. #1987 exposed it because it almost guarantees each file will have a unique system family.


If the user registers fonts like this:

registerFont("OpenSans-Bold.ttf", {family: "Open Sans", weight: 300});
registerFont("Arimo-Regular.ttf", {family: "Open Sans", weight: 600});

The font_face_list will look like this (approximated system descriptions):

OpenSans-Bold.ttf sys desc user desc
family Open Sans Open Sans
weight 600 300
Arimo-Regular.ttf sys desc user desc
family Arimo Open Sans
weight 400 600

When the user does this:

ctx.font = "600 Open Sans";

We should send this to the OS:

Arimo-Regular.ttf sys desc
family Arimo, Open Sans
weight 400

But we were sending this:

Arimo-Regular.ttf user desc
family Open Sans, Arimo
weight 400

fixes #2041

the problem was exposed by #1987, but was always there

fixes #2041
@zbjornson zbjornson merged commit 6fa9f38 into master Jun 24, 2022
@zbjornson zbjornson deleted the ch/2041 branch June 24, 2022 19:21
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.

2.9.1 fails to load the correct weights in the same font family
2 participants