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

Add tests for font weight + fix Google Font loading #7426

Merged
merged 3 commits into from
Dec 15, 2024

Conversation

davepagurek
Copy link
Contributor

There was already a textWeight() method, but it wasn't quite working with variable fonts for a few reasons, so this PR fixes that up.

Changes include:

  • loadFont() with a CSS font declaration or a URL to a one (e.g. from Google fonts) now works again.
    • This case is detected with an HTTP HEAD request to check for a text/css content type, and a check for @font-face in the contents.
    • I now parse the FontFace descriptors out of the CSS rules so that the font we add to the DOM still supports weight variations declared in the CSS
  • textWeight() now makes sure that both the 2D context's font property has the weight in it, and also that the canvas element has the right fontVariationSettings style applied for Chrome
  • A fix for the default font color in WebGL mode when no fill has been set by the user yet to match 2D mode behaviour (we change the fill to black for text)
  • Fixes a bug where the font family name parsed out of Typr breaks font face loading
  • Fixes a bug where font family names with numbers in them were being incorrectly parsed as font sizes

@davepagurek davepagurek merged commit 9200df4 into dev-2.0 Dec 15, 2024
2 checks passed
@davepagurek davepagurek deleted the feat/font-loading-weight branch December 15, 2024 15:47
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