Skip to content

Commit

Permalink
fix: measureText
Browse files Browse the repository at this point in the history
  • Loading branch information
dineug committed Jan 4, 2024
1 parent 59d1e14 commit 2b27f64
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/erd-editor-app/src/utils/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,9 @@ function getCanvasContext() {

export function toWidth(text: string) {
const canvasContext = getCanvasContext();
let width = 0;

if (canvasContext) {
width = canvasContext
? canvasContext.measureText(text).width
: text.length * 11;
}
const width = canvasContext
? canvasContext.measureText(text).width
: text.length * 11;

return Math.round(width) + TEXT_PADDING;
}

0 comments on commit 2b27f64

Please sign in to comment.