From 95ac01cf21d36224d2682bda97b584c7af6cc31a Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Thu, 11 Apr 2024 10:21:15 +0700 Subject: [PATCH] fix(web): fixes key-cap font scaling when very small text is required (#11203) --- .../main/java/com/keyman/engine/KMKeyboard.java | 2 +- web/src/engine/osk/src/keyboard-layout/oskKey.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java b/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java index a356a20ad55..bd1bfb6d2f2 100644 --- a/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java +++ b/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java @@ -229,7 +229,7 @@ public void initKMKeyboard(final Context context) { getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); getSettings().setSupportZoom(false); - + getSettings().setMinimumFontSize(4); getSettings().setUseWideViewPort(true); getSettings().setLoadWithOverviewMode(true); if (0 != (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)) { diff --git a/web/src/engine/osk/src/keyboard-layout/oskKey.ts b/web/src/engine/osk/src/keyboard-layout/oskKey.ts index 34ee93e300e..8c2f21a4464 100644 --- a/web/src/engine/osk/src/keyboard-layout/oskKey.ts +++ b/web/src/engine/osk/src/keyboard-layout/oskKey.ts @@ -231,10 +231,16 @@ export default abstract class OSKKey { proportion = yProportion; } - // Never upscale keys past the default * the specified scale - only downscale them. - // Proportion < 1: ratio of key width to (padded [loosely speaking]) text width - // maxProportion determines the 'padding' involved. - return ParsedLengthStyle.forScalar(scale * Math.min(proportion, 1)); + /* + Never upscale keys past the default - only downscale them. Proportion < + 1: ratio of key width to (padded [loosely speaking]) text width + maxProportion determines the 'padding' involved. + + Due to behaviors noted with #11203, we use fixed-size scaling based on the + relative font-size specifications; this forces font-size scaling even when + the resulting text becomes smaller than WebView-default thresholds. + */ + return originalSize.scaledBy(Math.min(proportion, 1)); } public get keyText(): string {