From 2ecb510cb1bcf63289a9ee453d250f2f2cc5b82c Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 3 Jul 2023 16:40:59 +0200 Subject: [PATCH] input: rendering issues with big font sizes --- CHANGELOG.md | 5 +++++ src/client/widgets/basics/input.js | 21 ++++++++++++--------- src/scss/widgets/basics.scss | 1 + 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f28b8b5..0f7083ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.25.3 + +- bug fixes + - input: rendering issues with big font sizes + ## 1.25.2 - bug fixes diff --git a/src/client/widgets/basics/input.js b/src/client/widgets/basics/input.js index a58a9394..6f56d778 100644 --- a/src/client/widgets/basics/input.js +++ b/src/client/widgets/basics/input.js @@ -133,12 +133,12 @@ class Input extends Canvas { resizeHandle(event){ - if (this.fontSize && event.height !== this.fontSize) { - // little hack to prevent flex layout issues - // alternate fix is to set css 'height: 100%;' on the canvas element - // but it produces a big drawing context for just one line of text. - event.height = this.fontSize - } + // if (this.fontSize && event.height !== this.fontSize) { + // // little hack to prevent flex layout issues + // // alternate fix is to set css 'height: 100%;' on the canvas element + // // but it produces a big drawing context for just one line of text. + // event.height = this.fontSize + // } super.resizeHandle(event) @@ -198,12 +198,15 @@ class Input extends Canvas { this.ctx.fillStyle = this.cssVars.colorText + // hack ? prevent weird offset added for unknown reason when font size increases + var offy = this.fontSize / 10; + if (this.textAlign == 'center') { - this.ctx.fillText(v, Math.round(width/2), Math.round(height/2)) + this.ctx.fillText(v, Math.round(width/2), Math.round(height/2 + offy)) } else if (this.textAlign == 'right') { - this.ctx.fillText(v, width, Math.round(height/2)) + this.ctx.fillText(v, width, Math.round(height/2 + offy)) } else { - this.ctx.fillText(v, 0, Math.round(height/2)) + this.ctx.fillText(v, 0, Math.round(height/2 + offy)) } this.clearRect = [0, 0, width, height] diff --git a/src/scss/widgets/basics.scss b/src/scss/widgets/basics.scss index bdf6f31d..bf734186 100644 --- a/src/scss/widgets/basics.scss +++ b/src/scss/widgets/basics.scss @@ -588,6 +588,7 @@ canvas { flex:1; max-width: 100%; + height: 100%; } input {