feature: Font.name_far_east #154
Copy link
Copy link
Open
Labels
Description
I find in there http://python-docx.readthedocs.org/en/latest/api/text.html#docx.text.run.Font
the font object has a name attribute, and i want to use a custome font. Where should i put the font's file(.otf)?
run.font.name = "Adobe 楷体 Std R"#this the font's name. Should i use the font's file name to replace the font's name ?
I try use it, but useless. What should I do?
Thanks.
Reactions are currently unavailable
Activity
scanny commentedon Mar 6, 2015
The name that Word uses for some fonts is unpredictable. In general, if it doesn't work the way it's spelled in the Word UI, the most direct approach is to use Word to apply the font to some text in a very small document (like a single word in a single paragraph), save the file, and then use opc-diag to examine the document.xml part.
The proper name to use will appear there, something like this:
If they differ, you want the one in
w:asciiandw:hAnsi. I believe python-docx sets them both to the same value.T4erg commentedon Mar 6, 2015
I find the 'w:ascii' and use the name. It still doesn't work. My code as follow:
I will try other way to solve it.
Thanks again.
scanny commentedon Mar 7, 2015
What do you find when you compare the XML produced by python-docx and that produced by Word? It could be that Word is using the font in the
w:eastAsiaattribute for text in Asian unicode character groups.[-]How to use a custome font[/-][+]feature: Font.name_far_east[/+]T4erg commentedon Mar 7, 2015
Excited! You remind me!
The w:ascii and w:eastAsia are correct But the w:hAnsi was INCORRECT.
This line was appear before the WORDS that I want to change.
The followe line was the WORDS and the attribute are correct. But didn't have the w:hAnsi attribute, But display INCORRECT.
scanny commentedon Mar 7, 2015
You should be able to add a
w:eastAsiaattribute like this:T4erg commentedon Mar 8, 2015
Thanks a lot. It works.
But the last line should be as follows:
scanny commentedon Mar 9, 2015
Ah, yes, of course, thanks @Taerg-L, I've corrected that.
I'm reopening this issue to act as a feature request to add
Font.name_far_eastto the API.monkey2000 commentedon Feb 2, 2017
Hey @scanny , this problem can be easily patched by PR #329 . Unfortunately, @leonzhu211 forgot to update the unit test. More info at Travis.
fengdasuk19 commentedon Feb 13, 2020
This issue can be fixed by PR #781, which updates the unit test code for PR #329 . @scanny