mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-03-24 19:33:33 +01:00
Initial import
This commit is contained in:
29
ebook_converter/ebooks/docx/theme.py
Normal file
29
ebook_converter/ebooks/docx/theme.py
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python2
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
|
||||
class Theme(object):
|
||||
|
||||
def __init__(self, namespace):
|
||||
self.major_latin_font = 'Cambria'
|
||||
self.minor_latin_font = 'Calibri'
|
||||
self.namespace = namespace
|
||||
|
||||
def __call__(self, root):
|
||||
for fs in self.namespace.XPath('//a:fontScheme')(root):
|
||||
for mj in self.namespace.XPath('./a:majorFont')(fs):
|
||||
for l in self.namespace.XPath('./a:latin[@typeface]')(mj):
|
||||
self.major_latin_font = l.get('typeface')
|
||||
for mj in self.namespace.XPath('./a:minorFont')(fs):
|
||||
for l in self.namespace.XPath('./a:latin[@typeface]')(mj):
|
||||
self.minor_latin_font = l.get('typeface')
|
||||
|
||||
def resolve_font_family(self, ff):
|
||||
if ff.startswith('|'):
|
||||
ff = ff[1:-1]
|
||||
ff = self.major_latin_font if ff.startswith('major') else self.minor_latin_font
|
||||
return ff
|
||||
Reference in New Issue
Block a user