Conversion: Handle input documents with crazy font sizes (1000pt +)

This commit is contained in:
Kovid Goyal 2014-11-02 10:13:32 +05:30
parent 1fd7e6ae55
commit 787184f15b

View File

@ -62,9 +62,17 @@ class KeyMapper(object):
endp = 0 if size < base else 36 endp = 0 if size < base else 36
diff = (abs(base - size) * 3) + ((36 - size) / 100) diff = (abs(base - size) * 3) + ((36 - size) / 100)
logb = abs(base - endp) logb = abs(base - endp)
if logb == 0: try:
logb = 1e-6 result = sign * math.log(diff, logb)
result = sign * math.log(diff, logb) except ValueError:
if diff < 0:
# Size is both very large and close to base
return 0
if logb == 0:
logb = 1e-6
if diff == 0:
diff = 1e-6
result = sign * math.log(diff, logb)
return result return result
def __getitem__(self, ssize): def __getitem__(self, ssize):