Skip to content

Commit

Permalink
fix: apply skipFonts option
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo authored and istaiti committed Feb 7, 2023
1 parent d2ee5f6 commit e6f27b0
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/embed-webfonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,20 @@ export async function embedWebFonts<T extends HTMLElement>(
const cssText =
options.fontEmbedCSS != null
? options.fontEmbedCSS
: options.skipFonts
? null
: await getWebFontCSS(clonedNode, options)
const styleNode = document.createElement('style')
const sytleContent = document.createTextNode(cssText)

styleNode.appendChild(sytleContent)
if (cssText) {
const styleNode = document.createElement('style')
const sytleContent = document.createTextNode(cssText)

if (clonedNode.firstChild) {
clonedNode.insertBefore(styleNode, clonedNode.firstChild)
} else {
clonedNode.appendChild(styleNode)
styleNode.appendChild(sytleContent)

if (clonedNode.firstChild) {
clonedNode.insertBefore(styleNode, clonedNode.firstChild)
} else {
clonedNode.appendChild(styleNode)
}
}
}

0 comments on commit e6f27b0

Please sign in to comment.