Skip to content

Commit

Permalink
Add option to not copy web fonts
Browse files Browse the repository at this point in the history
This will (optionally) reduce the size of the SVG and speed things up when no fonts need to be copied.
Thanks to @davidburns573 and @YujiaCheng1996
Fixes #158
  • Loading branch information
IDisposable committed Aug 21, 2024
1 parent 45be8f2 commit 5b003ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dom-to-image-more.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
* @param {Boolean} options.cacheBust - set to true to cache bust by appending the time to the request url
* @param {String} options.styleCaching - set to 'strict', 'relaxed' to select style caching rules
* @param {Boolean} options.copyDefaultStyles - set to false to disable use of default styles of elements
* @param {Boolean} options.disableEmbedFonts - set to true to disable font embedding into the SVG output.
* @param {Object} options.corsImg - When the image is restricted by the server from cross-domain requests, the proxy address is passed in to get the image
* - @param {String} url - eg: https://cors-anywhere.herokuapp.com/
* - @param {Enumerator} method - get, post
Expand All @@ -95,12 +96,13 @@
options = options || {};
copyOptions(options);
let restorations = [];

return Promise.resolve(node)
.then(ensureElement)
.then(function (clonee) {
return cloneNode(clonee, options, null, ownerWindow);
})
.then(embedFonts)
.then(options.disableEmbedFonts ? Promise.resolve(node) : embedFonts)
.then(inlineImages)
.then(applyOptions)
.then(makeSvgDataUri)
Expand Down Expand Up @@ -605,6 +607,7 @@
return node;
});
}

function newUtil() {
let uid_index = 0;

Expand Down

0 comments on commit 5b003ca

Please sign in to comment.