Skip to content

Commit

Permalink
fix: use getPixelRatio()
Browse files Browse the repository at this point in the history
  • Loading branch information
hzsrc committed Aug 16, 2024
1 parent f5afad4 commit 5b7cfe2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export async function nodeToDataURL(
const foreignObject = document.createElementNS(xmlns, 'foreignObject')

// fix: if ratio=2 and style.border='1px', in html it is actually rendered to 1px, but in <img src="svg"> it is rendered to 2px. Then height is different and the bottom 1px is lost, 10 nodes will lost 10px.
var ratio = self.devicePixelRatio;
var ratio = getPixelRatio();
svg.setAttribute('width', `${width / ratio}`)
svg.setAttribute('height', `${height / ratio}`)
svg.setAttribute('viewBox', `0 0 ${width} ${height}`)
Expand Down

0 comments on commit 5b7cfe2

Please sign in to comment.