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

font[inline] #649

Closed
emilos opened this issue Aug 18, 2020 · 7 comments
Closed

font[inline] #649

emilos opened this issue Aug 18, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@emilos
Copy link
Contributor

emilos commented Aug 18, 2020

We'd like to add inlining support for font tags too. This behavior is already implemented for <style inline tags and can potentially be reused for this new use case.

Some related code can be found here https://github.com/buxlabs/boxwood/blob/master/src/plugins/InlinePlugin.js#L54

This way, the following code:

<font Nunito from="assets/fonts/Nunito.ttf" inline />

should be transformed into a style tag, that has a base64 representation of the font.

@emilos emilos added the enhancement New feature or request label Aug 18, 2020
@inikonorov
Copy link
Contributor

inikonorov commented Aug 25, 2020

I decided that it is easier task, than others and try to do this! I have a question - is it okay, that boxwood can't works with inline style tag which contains links on local files? When I try to use div { background: url(./logo.jpg) } in inline style tag, boxwood outputs <style>div{background:url(./logo.jpg)}</style> instead of base64 encoded image

@emilos
Copy link
Contributor Author

emilos commented Aug 25, 2020

@inikonorov it should handle this case correctly, here's a test:

https://github.com/buxlabs/boxwood/blob/master/test/spec/tags/style/inline.spec.js

you need to specify a paths compiler option so that the compiler knows where to look for files :)

@inikonorov
Copy link
Contributor

okay, thanks!

@inikonorov
Copy link
Contributor

hmm, I write code, that turns file url to base64, but there is a problem - base64 string is not correct. When I try to put <style> tag with @font-face with getting base64 string, I get the error net::ERR_INVALID_URL. I tried to get base64 string of font via different services and every service gave me the string, that not equal to string from fs.readFile. Don't know what to do :(

@emilos
Copy link
Contributor Author

emilos commented Aug 26, 2020

@inikonorov thanks for looking into this :). I had a similar problem when I was implementing something similar. I think you can just reuse some of the existing code for this.

Inside of tags/font.js we just inline the font declaration there. If inline attribute is present, we want to reuse some of the code from InlinePlugin to do the inlining, the same way. For this issue, we need to figure out how to reuse that code.

@inikonorov
Copy link
Contributor

#653

@emilos
Copy link
Contributor Author

emilos commented Aug 27, 2020

@inikonorov thanks!

@emilos emilos closed this as completed Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants