I found that if the styles.css sheet has a font-size: 0, the calculation here doesn't give the expected 'ans'.
@kovidgoyal How about this idea? Do not calculationif 'fs' is 0.
paged_mode.pyj
def cps_by_em_size():
ans = cps_by_em_size.ans
fs = window.getComputedStyle(document.body).fontSize
if not ans or cps_by_em_size.at_font_size is not fs:
d = document.createElement('span')
d.style.position = 'absolute'
d.style.visibility = 'hidden'
d.style.width = '1rem'
d.style.fontSize = '1rem'
d.style.paddingTop = d.style.paddingBottom = d.style.paddingLeft = d.style.paddingRight = '0'
d.style.marginTop = d.style.marginBottom = d.style.marginLeft = d.style.marginRight = '0'
d.style.borderStyle = 'none'
document.body.appendChild(d)
w = d.clientWidth
document.body.removeChild(d)
ans = cps_by_em_size.ans = max(2, w)
cps_by_em_size.at_font_size = fs
return ans