mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Special case zero font size when calculating columns per screen in paged mode
This commit is contained in:
parent
ce49025770
commit
603dcc777e
@ -152,18 +152,21 @@ 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)
|
||||
if fs is 0:
|
||||
ans = cps_by_em_size.ans = 16
|
||||
else:
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user