mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-22 15:47:41 +00:00
fix(web): font size on key preview
Font size adjustment needed an override for the key preview to prevent it using the base key font size as a starting point.
This commit is contained in:
parent
d3136b8860
commit
a2aef99c3e
2 changed files with 10 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue