Skip to content

Commit

Permalink
Fix cutting off part of text when adding text to zoomed image
Browse files Browse the repository at this point in the history
Fix #191
  • Loading branch information
crmtestresco committed Oct 18, 2023
1 parent d202116 commit 08ff961
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,17 @@ export default class TextTool {
apply() {
const origBorder = this.input.style.border;
const scale = this.main.getScale();

this.input.style.border = 'none';
domtoimage.toPng(this.input, {
const domToImageConfig = {
style: {
'transform-origin': 'top left',
transform: `scale(${scale})`
},
width: this.input.clientWidth * scale,
height: this.input.clientHeight * scale,
})
width: this.input.clientWidth * (scale < 1 ? (1 / scale) : scale),
height: this.input.clientHeight * (scale < 1 ? (1 / scale) : scale),
};
domtoimage.toPng(this.input, domToImageConfig)
.then((dataUrl) => {
const img = new Image();
img.src = dataUrl;
Expand Down

0 comments on commit 08ff961

Please sign in to comment.