Skip to content

specify fontFamily to filter fonts#282

Open
NotsayJustdo wants to merge 1 commit intotsayen:masterfrom
NotsayJustdo:master
Open

specify fontFamily to filter fonts#282
NotsayJustdo wants to merge 1 commit intotsayen:masterfrom
NotsayJustdo:master

Conversation

@NotsayJustdo
Copy link
Copy Markdown

Hi, if many fonts in stylesheets, dom-to-image will download all fonts, it will cause some problems: 1. waiting long time to load all fonts 2. use large computer memories, maybe make the browser breakdown. I suggest to add fontFamily option for user, user can specify they use fontFamily, it will avoid that problems!

if many fonts in stylesheets, dom-to-image will download all fonts, it will cause some problems: 1. waiting long time to load all fonts  2. use large computer memories, maybe make the browser breakdown. I suggest to add fontFamily option for user, user can specify they use fontFamily, it will avoid that problems!
Copy link
Copy Markdown

@IDisposable IDisposable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting fix, but a breaking change as it will not add a rule that sets multiple properties and a font-face... so some styling that might be applied/overridden will be lost.

Comment thread src/dom-to-image.js
for (let i = 0; domtoimage.impl.options.fontFamily[i]; i++) {
if (rule.cssText.indexOf(domtoimage.impl.options.fontFamily[i]) !== -1) {
flag = true
break
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick code style of this repository requires trailing ;

Comment thread src/dom-to-image.js

function copyOptions(options) {
// get user specifiy fontFamily
domtoimage.impl.options.fontFamily = options.fontFamily || []
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should alias this to a local var to reduce double-dotting

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.

2 participants