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

Feature/add option to skip embedding font while generating SVG image #452

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ Set to true to append the current time as a query string to URL requests to enab

A data URL for a placeholder image that will be used when fetching an image fails. Defaults to undefined and will throw an error on failed images

#### skipFonts

Whether to skip downloading and embedding fonts. This should not be used if
you use icon fonts or other fonts you need to show in the image. Defaults to false.

## Browsers

It's tested on latest Chrome and Firefox (49 and 45 respectively at the time
Expand Down
4 changes: 2 additions & 2 deletions dist/dom-to-image.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/dom-to-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
defaults to 1.0.
* @param {String} options.imagePlaceholder - dataURL to use as a placeholder for failed images, default behaviour is to fail fast on images we can't fetch
* @param {Boolean} options.cacheBust - set to true to cache bust by appending the time to the request url
* @param {Boolean} options.skipFonts - Whether to skip downloading fonts (default: false)
* @return {Promise} - A promise that is fulfilled with a SVG image data URL
* */
function toSvg(node, options) {
Expand All @@ -57,7 +58,12 @@
.then(function (node) {
return cloneNode(node, options.filter, true);
})
.then(embedFonts)
.then(function(node) {
if (!options || !options.skipFonts){
return embedFonts(node);
}
return node;
})
.then(inlineImages)
.then(applyOptions)
.then(function (clone) {
Expand Down