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

fix issue 328 #329

Closed
wants to merge 3 commits into from
Closed

fix issue 328 #329

wants to merge 3 commits into from

Conversation

IgnacioHR
Copy link
Contributor

Summary

As stated in issue 328, this pull request provides access to the generated fonts in base64 formats so it is possible to embed the font inside the scss file while generating it (this is my particular use case)

Proposed changes

The proposed change is to add "fonts" to nunjucksOptions and one key for each generated font. Then, the key value is the base64 encoded content of the array (or generated file)

Related issue

Issue 328

Dependencies added/removed (if applicable)

None


How to test

I've modified line 68 of template.html.njk as follows:

from:
url("{{ fontPath }}{{ fontName }}.woff2?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}") format("woff2")
to
url("data:font/woff2;base64,{{ fonts.woff2 }}") format("woff2")

And tested the document in a browser (Chrome), then, in the network tab you can see the font has been loaded from embeded resource rather than external URL.

Test configuration

Same original configuration

@IgnacioHR
Copy link
Contributor Author

I've just provided an alternative code based on feedback from appveyor/pr

@jimmyandrade
Copy link
Collaborator

@IgnacioHR thanks! The codebase has changed a little since your last commit. Could you take a look please?

jimmyandrade pushed a commit that referenced this pull request May 12, 2021
Fixes #328 and #329

This commit also prevent running conditions with webfont result.

Co-Authored-By: IgnacioHR <16385090+IgnacioHR@users.noreply.github.com>
@jimmyandrade
Copy link
Collaborator

@IgnacioHR thanks for contributing!

This PR was released as Webfont 11.1 and already available at npm.

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.

None yet

2 participants