elapouya / python-docx-template

Use a docx as a jinja2 template
GNU Lesser General Public License v2.1
1.98k stars 385 forks source link

Update richtext.py #452

Closed sailingnn closed 2 years ago

sailingnn commented 2 years ago

add support for eastAsia fonts in RichText

elapouya commented 2 years ago

Thank you for your PR, but I cannot merge it : it is too specific to eastAsia : it should work with all other regions. May be I have to create a specific syntax... Could you give one working example (template + python code) ?

sailingnn commented 2 years ago

Hi Eric,

First of all, thank you sooooo much for all your work! 

Let me explain the eastAsia thing. Without this, everything in English works fine but with Chinese, it does not. For example, if I want a Microsoft YaHei font,which belongs to eastAsia fonts, with my richtext part, it does not change the font.

I've attached the template and python code to the attachment. And below are detail explanations with pictures.

This picture is what it should be.

And This picture is what it does with your original program. It works fine for Engligh, but not for Chinese characters.

Hope I've fully explained the situation.

Best regards, Dongfang Song

------------------ 原始邮件 ------------------ 发件人: "elapouya/python-docx-template" @.>; 发送时间: 2022年8月2日(星期二) 晚上9:29 @.>; @.**@.>; 主题: Re: [elapouya/python-docx-template] Update richtext.py (PR #452)

Thank you for your PR, but I cannot merge it : it is too specific to eastAsia : it should work with all other regions. May be I have to create a specific syntax... Could you give one working example (template + python code) ?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

elapouya commented 2 years ago

Hello,

The attachments and images are not available when transmitted by email, you have to go to github interface and drag&drop them I think.

sailingnn commented 2 years ago

My fault. I've added a template and python code. I tested them on the Windows system. This picture is what it should be. image

elapouya commented 2 years ago

I modified your code to make it more generic. There is a specific syntax for regional fonts : Have a look at tests/richtext_eastAsia.py

Please could you confirm it works your side ?

sailingnn commented 2 years ago

Yeah, it works! Thanks again for your work!