diff --git a/web/source/osk/browser/keytip.ts b/web/source/osk/browser/keytip.ts index 7874abbf0e..d19621d1b2 100644 --- a/web/source/osk/browser/keytip.ts +++ b/web/source/osk/browser/keytip.ts @@ -86,7 +86,7 @@ namespace com.keyman.osk.browser { height: 1.6 * xHeight + 'px' // as opposed to the canvas height of 2.3 * xHeight. }; - kts.fontSize = key.key.getIdealFontSize(vkbd, scaleStyle); + kts.fontSize = key.key.getIdealFontSize(vkbd, scaleStyle, true); } this.label.textContent = kc.textContent; diff --git a/web/source/osk/oskKey.ts b/web/source/osk/oskKey.ts index d156c07b27..feb108645d 100644 --- a/web/source/osk/oskKey.ts +++ b/web/source/osk/oskKey.ts @@ -300,7 +300,14 @@ namespace com.keyman.osk { return metrics; } - getIdealFontSize(vkbd: VisualKeyboard, style: {height?: string, fontFamily?: string, fontSize: string}): string { + /** + * Calculate the font size required for a key cap, scaling to fit longer text + * @param vkbd + * @param style specification for the desired base font size + * @param override if true, don't use the font spec from the button, just use the passed in spec + * @returns font size as a style string + */ + getIdealFontSize(vkbd: VisualKeyboard, style: {height?: string, fontFamily?: string, fontSize: string}, override?: boolean): string { let buttonStyle = getComputedStyle(this.btn); let keyWidth = parseFloat(buttonStyle.width); let emScale = 1; @@ -316,7 +323,7 @@ namespace com.keyman.osk { // Recompute the new width for use in autoscaling calculations below, just in case. emScale = vkbd.getKeyEmFontSize(); keyWidth = this.getKeyWidth(vkbd); - } else { + } else if(!override) { // When available, just use computedStyle instead. style = buttonStyle; }