diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py
index 0fc9c10e25..011c0f6a8d 100644
--- a/src/calibre/ebooks/html.py
+++ b/src/calibre/ebooks/html.py
@@ -788,7 +788,10 @@ class Processor(Parser):
size = '3'
if size and size.strip() and size.strip()[0] in ('+', '-'):
size = 3 + float(size) # Hack assumes basefont=3
- setting = 'font-size: %d%%;'%int((float(size)/3) * 100)
+ try:
+ setting = 'font-size: %d%%;'%int((float(size)/3) * 100)
+ except ValueError:
+ setting = ''
face = font.attrib.pop('face', None)
if face is not None:
setting += 'font-face:%s;'%face
diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py
index 5e553dcdd5..779bdf8067 100644
--- a/src/calibre/ebooks/mobi/reader.py
+++ b/src/calibre/ebooks/mobi/reader.py
@@ -234,6 +234,15 @@ class MobiReader(object):
def cleanup_soup(self, soup):
if self.verbose:
print 'Replacing height, width and align attributes'
+ size_map = {
+ 'xx-small' : '0.5',
+ 'x-small' : '1',
+ 'small' : '2',
+ 'medium' : '3',
+ 'large' : '4',
+ 'x-large' : '5',
+ 'xx-large' : '6',
+ }
for tag in soup.recursiveChildGenerator():
if not isinstance(tag, Tag): continue
styles = []
@@ -258,6 +267,15 @@ class MobiReader(object):
pass
if styles:
tag['style'] = '; '.join(styles)
+
+ if tag.name.lower() == 'font':
+ sz = tag.get('size', '')
+ try:
+ float(sz)
+ except ValueError:
+ sz = sz.lower()
+ if sz in size_map.keys():
+ tag['size'] = size_map[sz]
def create_opf(self, htmlfile, guide=None):
mi = self.book_header.exth.mi