diff --git a/web/source/kmwutils.ts b/web/source/kmwutils.ts index 0bfd8a1ed6..071a526fbc 100644 --- a/web/source/kmwutils.ts +++ b/web/source/kmwutils.ts @@ -374,11 +374,22 @@ namespace com.keyman { } else if(fs.indexOf('px') != -1) { val = parseFloat(fs.substr(0, fs.indexOf('px'))); return {val: val, absolute: true}; + } else if(fs.indexOf('pt') != -1) { + // 16 px ~= 12 pt. + // Reference: https://kyleschaeffer.com/css-font-size-em-vs-px-vs-pt-vs-percent + val = parseFloat(fs.substr(0, fs.indexOf('pt'))); + return {val: (4 * val / 3), absolute: true}; } else if(fs.indexOf('%') != -1) { val = parseFloat(fs.substr(0, fs.indexOf('%'))); return {val: val/100, absolute: false}; + } else if(!isNaN(val = Number(fs))) { + // Note: this one is NOT natively handled by browsers! + // We'll treat it as if it were 'pt', since that's likely the user's + // most famiilar font size unit. + return {val: (4 * val / 3), absolute: true}; } else { // Cannot parse. + console.error("Could not properly parse specified fontsize info: '" + fs + "'."); return null; } }