Fix mapping of text-indent to parindent.

This commit is contained in:
Kovid Goyal 2007-08-16 15:44:16 +00:00
parent 3d007aacf1
commit 2350a75c22

View File

@ -53,10 +53,11 @@ class Span(_Span):
@staticmethod @staticmethod
def unit_convert(val, dpi, ref=80): def unit_convert(val, dpi, ref=80, pts=False):
""" """
Tries to convert html units stored in C{val} to pixels. Tries to convert html units stored in C{val} to pixels.
@param ref: reference size in pixels for % units. @param ref: reference size in pixels for % units.
@param pts: If True return 10*pts instead of pixels.
@return: The number of pixels (an int) if successful. Otherwise, returns None. @return: The number of pixels (an int) if successful. Otherwise, returns None.
Assumes: One em is 10pts Assumes: One em is 10pts
""" """
@ -80,6 +81,8 @@ class Span(_Span):
result = int(unit * 0.04 * (dpi/72.)) result = int(unit * 0.04 * (dpi/72.))
elif m.group(2)== 'cm': elif m.group(2)== 'cm':
result = int(unit * 0.4 * (dpi/72.)) result = int(unit * 0.4 * (dpi/72.))
if pts:
result = int((float(result)/dpi)*720)
return result return result
@staticmethod @staticmethod
@ -1195,9 +1198,10 @@ class HTMLConverter(object):
return return
self.lstrip_toggle = True self.lstrip_toggle = True
if tag_css.has_key('text-indent'): if tag_css.has_key('text-indent'):
indent = Span.unit_convert(tag_css['text-indent'], self.profile.dpi) indent = Span.unit_convert(tag_css['text-indent'], self.profile.dpi, pts=True)
if not indent: if not indent:
indent = 0 indent = 0
else: else:
indent = self.book.defaultTextStyle.attrs['parindent'] indent = self.book.defaultTextStyle.attrs['parindent']
if indent != self.current_block.textStyle.attrs['parindent']: if indent != self.current_block.textStyle.attrs['parindent']: