Merge branch 'master' of https://github.com/sailingnn/python-docx-template into sailingnn-master
This commit is contained in:
commit
ea987f9e38
@ -79,7 +79,7 @@ class RichText(object):
|
|||||||
if strike:
|
if strike:
|
||||||
prop += u'<w:strike/>'
|
prop += u'<w:strike/>'
|
||||||
if font:
|
if font:
|
||||||
prop += (u'<w:rFonts w:ascii="{font}" w:hAnsi="{font}" w:cs="{font}"/>'
|
prop += (u'<w:rFonts w:ascii="{font}" w:hAnsi="{font}" w:cs="{font}" w:eastAsia="{font}"/>'
|
||||||
.format(font=font))
|
.format(font=font))
|
||||||
|
|
||||||
xml = u'<w:r>'
|
xml = u'<w:r>'
|
||||||
|
|||||||
18
tests/richtext_eastAsia.py
Normal file
18
tests/richtext_eastAsia.py
Normal file
@ -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')
|
||||||
BIN
tests/templates/richtext_eastAsia_tpl.docx
Normal file
BIN
tests/templates/richtext_eastAsia_tpl.docx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user