From 32eb5130225337f546337fa10c7a6883c6f6535a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 22 Mar 2008 23:50:15 +0000 Subject: [PATCH] Fix #596 --- src/libprs500/ebooks/lrf/html/convert_from.py | 4 ++++ src/libprs500/ebooks/lrf/pylrs/pylrf.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/libprs500/ebooks/lrf/html/convert_from.py b/src/libprs500/ebooks/lrf/html/convert_from.py index f14edcb1c2..3858cbc4bd 100644 --- a/src/libprs500/ebooks/lrf/html/convert_from.py +++ b/src/libprs500/ebooks/lrf/html/convert_from.py @@ -1079,6 +1079,10 @@ class HTMLConverter(object): if 2*int(ans['sidemargin']) >= factor*int(self.current_block.blockStyle.attrs['blockwidth']): ans['sidemargin'] = int((factor*int(self.current_block.blockStyle.attrs['blockwidth']))/2.) + for prop in ('topskip', 'footskip', 'sidemargin'): + if ans[prop] < 0: + ans[prop] = 0 + return ans def font_properties(self, css): diff --git a/src/libprs500/ebooks/lrf/pylrs/pylrf.py b/src/libprs500/ebooks/lrf/pylrs/pylrf.py index 8cab70cbc3..d0dbd4a609 100644 --- a/src/libprs500/ebooks/lrf/pylrs/pylrf.py +++ b/src/libprs500/ebooks/lrf/pylrs/pylrf.py @@ -78,7 +78,10 @@ def writeByte(f, byte): def writeWord(f, word): if int(word) > 65535: raise LrfError('Cannot encode a number greater than 65535 in a word.') + if int(word) < 0: + raise LrfError('Cannot encode a number < 0 in a word: '+str(word)) f.write(struct.pack("