Merge pull request #13960 from keymanapp/fix/web/cherry-default-layout-font-scaling

fix(web): empty layout fontSize property should default to 1em 🍒  🏠
This commit is contained in:
Marc Durdin 2025-05-16 21:06:55 +07:00 committed by GitHub
commit 045f559ad2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View file

@ -521,11 +521,15 @@ export default abstract class OSKView
// Set default OSK font size (Build 344, KMEW-90)
// If the layer group specifies a fontsize value, we need
// to apply that to the banner as well.
const layerFontSizeRaw = this.vkbd?.layerGroup?.spec.fontsize;
let layerFontSizeRaw = this.vkbd?.layerGroup?.spec.fontsize;
if(layerFontSizeRaw === '') {
layerFontSizeRaw = "1em";
}
// Addresses issue with touch-layouts specifying a unitless fontsize; this
// coerces them to `pt` style sizing, like how word-processors present font-size.
//
// Returns NaN if not 100% a number. "12px", "12pt", "12%" all return NaN.
// Number() returns NaN if not 100% a number. "12px", "12pt", "12%" all return NaN.
// '' returns 0, though!
const fsRaw = Number(layerFontSizeRaw);
const layerFontSize = isNaN(fsRaw) ? layerFontSizeRaw : (fsRaw + 'pt');

View file

@ -1113,10 +1113,6 @@ export default class VisualKeyboard extends EventEmitter<EventMap> implements Ke
* This function allows us to calculate the font size in those situations.
*/
getKeyEmFontSize(): ParsedLengthStyle {
if (!this.fontSize) {
return new ParsedLengthStyle('0px');
}
if (this.device.formFactor == 'desktop') {
let keySquareScale = 0.8; // Set in kmwosk.css, is relative.
return this.fontSize.scaledBy(keySquareScale);
@ -1313,7 +1309,8 @@ export default class VisualKeyboard extends EventEmitter<EventMap> implements Ke
// All existing font-precalculations will need to be reset, as the font
// was previously unavailable.
this.layerGroup.resetPrecalcFontSizes();
this.refreshLayout()
// Can trigger when we're not actually layout-ready!
this.refreshLayout();
});
}