mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
DOCX Input: Add support for text whose vertical position is adjusted by offsets from the baseline
This commit is contained in:
parent
78a269d983
commit
2cd0c92224
@ -122,6 +122,16 @@ def read_vert_align(parent, dest, XPath, get):
|
|||||||
ans = val
|
ans = val
|
||||||
setattr(dest, 'vert_align', ans)
|
setattr(dest, 'vert_align', ans)
|
||||||
|
|
||||||
|
def read_position(parent, dest, XPath, get):
|
||||||
|
ans = inherit
|
||||||
|
for col in XPath('./w:position[@w:val]')(parent):
|
||||||
|
val = get(col, 'w:val')
|
||||||
|
try:
|
||||||
|
ans = float(val)/2.0
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
setattr(dest, 'position', ans)
|
||||||
|
|
||||||
def read_font_family(parent, dest, XPath, get):
|
def read_font_family(parent, dest, XPath, get):
|
||||||
ans = inherit
|
ans = inherit
|
||||||
for col in XPath('./w:rFonts')(parent):
|
for col in XPath('./w:rFonts')(parent):
|
||||||
@ -142,7 +152,7 @@ class RunStyle(object):
|
|||||||
'rtl', 'shadow', 'smallCaps', 'strike', 'vanish', 'webHidden',
|
'rtl', 'shadow', 'smallCaps', 'strike', 'vanish', 'webHidden',
|
||||||
|
|
||||||
'border_color', 'border_style', 'border_width', 'padding', 'color', 'highlight', 'background_color',
|
'border_color', 'border_style', 'border_width', 'padding', 'color', 'highlight', 'background_color',
|
||||||
'letter_spacing', 'font_size', 'text_decoration', 'vert_align', 'lang', 'font_family',
|
'letter_spacing', 'font_size', 'text_decoration', 'vert_align', 'lang', 'font_family', 'position',
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle_properties = {
|
toggle_properties = {
|
||||||
@ -162,7 +172,7 @@ class RunStyle(object):
|
|||||||
):
|
):
|
||||||
setattr(self, p, binary_property(rPr, p, namespace.XPath, namespace.get))
|
setattr(self, p, binary_property(rPr, p, namespace.XPath, namespace.get))
|
||||||
|
|
||||||
for x in ('text_border', 'color', 'highlight', 'shd', 'letter_spacing', 'sz', 'underline', 'vert_align', 'lang', 'font_family'):
|
for x in ('text_border', 'color', 'highlight', 'shd', 'letter_spacing', 'sz', 'underline', 'vert_align', 'position', 'lang', 'font_family'):
|
||||||
f = globals()['read_%s' % x]
|
f = globals()['read_%s' % x]
|
||||||
f(rPr, self, namespace.XPath, namespace.get)
|
f(rPr, self, namespace.XPath, namespace.get)
|
||||||
|
|
||||||
@ -235,6 +245,9 @@ class RunStyle(object):
|
|||||||
if val is not inherit:
|
if val is not inherit:
|
||||||
c[x.replace('_', '-')] = '%.3gpt' % val
|
c[x.replace('_', '-')] = '%.3gpt' % val
|
||||||
|
|
||||||
|
if self.position is not inherit:
|
||||||
|
c['vertical-align'] = '%.3gpt' % val
|
||||||
|
|
||||||
if self.highlight is not inherit and self.highlight != 'transparent':
|
if self.highlight is not inherit and self.highlight != 'transparent':
|
||||||
c['background-color'] = self.highlight
|
c['background-color'] = self.highlight
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user