diff --git a/docxtpl/richtext.py b/docxtpl/richtext.py index f78d6ef..80b567e 100644 --- a/docxtpl/richtext.py +++ b/docxtpl/richtext.py @@ -79,7 +79,7 @@ class RichText(object): if strike: prop += u'' if font: - prop += (u'' + prop += (u'' .format(font=font)) xml = u'' diff --git a/tests/richtext_eastAsia.py b/tests/richtext_eastAsia.py new file mode 100644 index 0000000..168ad72 --- /dev/null +++ b/tests/richtext_eastAsia.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +''' +Created : 2022-08-03 +@author: Dongfang Song +''' +from docxtpl import DocxTemplate, RichText +tpl=DocxTemplate('templates/richtext_eastAsia_tpl.docx') +rt = RichText('测试TEST', font = 'Microsoft YaHei') +ch = RichText('测试TEST', font = '微软雅黑') +sun = RichText('测试TEST', font = 'SimSun') +context = { + 'example' : rt, + 'Chinese' : ch, + 'simsun' : sun, +} + +tpl.render(context) +tpl.save('output/richtext_eastAsia.docx') diff --git a/tests/templates/richtext_eastAsia_tpl.docx b/tests/templates/richtext_eastAsia_tpl.docx new file mode 100644 index 0000000..9f25fcf Binary files /dev/null and b/tests/templates/richtext_eastAsia_tpl.docx differ