-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Optimize downloading webfonts #37
Comments
Hi. Well, there is currently no setting that would limit external resources downloading. The library by itself is not so intelligent - it does not check whether the font declared via I can imagine adding a setting like "do not embed fonts", or also "embed only woff format for fonts" (that also might change the appearance of the result) - but that is currently not the case. |
So maybe we can try making the library intelligent to check if the fonts declared via @font-face are already loaded in the node we wish to render. I'd be happy to work on a pull request. A bit of direction as to where should i start would be helpful. |
One more thought: I would suppose that browser itself caches the fonts - so On Mon, Jun 6, 2016 at 6:57 AM, Vinay Bhinde notifications@github.com
|
You might be bypassing the cache, if you have font URLs like described here Solution that would not require changes to the lib would just be using font On Mon, Jun 6, 2016 at 7:26 AM, Anatoly Sayenko anatoly.sayenko@gmail.com
|
Yes i am hitting the cache and the font is not actually downloaded from the server so we are fine on that front. But i found another issue while checking this. What's happening is that each font file format is loaded 9 times ! This is not normal so there something wrong with this. How does the lib go about loading fonts it finds @font-face definition for ? If i can fix this i can reduce a lot of requests. |
I'll check whether adding a font cache would fix anything (each file will be downloaded still, but once) |
Hi, I am working on a desktop application where I'll never need the fonts because all the data that needs to be rendered comes from inline SVGs. Is there an easy way to completely bypass the embedFonts calls? |
Hi. If you don't have web fonts in your CSS, then there will be no network On Fri, Sep 9, 2016 at 2:25 PM, Carvel Avis notifications@github.com
|
Oh, I should have been more specific. And by the way, yours is the only script I've found that will do what I need. Thanks so much for making it available! This is an Electron app so it's all html, js and css. I do have one .woff file but it's local and doesn't apply to anything in the dom (div) element I'm trying to render. All that will ever be in that dom are multiple SVGs. It's capturing some rather heavy SVG animations at anywhere from 30-60 FPS (set by the user), converting to PNG sequence, then using FFMPEG to export them out to various formats - MP4, GIF or MOV file. Animations can be as long as a couple of minutes or more so I need to do anything possible to reduce the time it takes to parse through the animations. I notice that your script (in order to preserve transparency) has to parse through every node of every SVG in the DOM. I'd be willing to pay for some help with this. |
For now I've commented out the call to that function and it seems to be working ok.
|
OK, I see. The thing is that this lib might not be the right tool for the job. It is more for "make a page screenshot once in a while" kind of stuff. You might be much better off with directly rendering your SVG on This lib has to get all the web fonts it sees on the page, cause it cannot predict whether particular font is used in the node you're trying to render (OK, it theoretically could, but it's not implemented). |
I can imagine some kind of option like |
Yea, I see what you mean. The only thing is, there are multiple SVGs in the dom element wrapped by a div. I wonder if it would be a good idea to create a master SVG and embed all the others in it. |
+1 on an option to only load fonts being used in the node being made into an image |
I got the same issue, every time its calling same Font URL.
|
Any plans to fix this issue? I've got an app that is trying to generate several hundred images and it takes a very long time due to repeatedly loading fonts.
A font cache would work great for my case. Redownloading all the fonts once isn't a huge deal and would cut my total task time down to almost nothing I think. |
@tsayen would you be happy to accept a PR that calls UPD: Seems the PR is out there already: #92 |
Hi. I have added a small check that tracks which resources were already downloaded and simply skips if a resources wants to be downloaded again. It worked for my use case but didn't do any extensive testing. See the small code changes here. svigelj@487c431 |
we don't have to request for unnecessary fonts
|
Hello ,
I am having lots of fonts in my app and while generating png image there are many ajax calls for getting these font files from the server. As i need to support many browsers hence there are font's in different formats and right now for a single image to be generated from DOM, the count for fetching fonts goes above 100.
Due to browser trying to fetch so many fonts, it freezes for a while when generating image. Is there any way by which i can reduce these downloads or supply those fonts in some way so that we need not tell browser to fetch it exclusively again as they are already fetched ?
The text was updated successfully, but these errors were encountered: