Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
feature: Font.name_far_east #154
I find in there http://python-docx.readthedocs.org/en/latest/api/text.html#docx.text.run.Font
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.
$ opc browse test-doc.docx document.xml
The proper name to use will appear there, something like this:
<w:r w:rsidRPr="00392E92"> <w:rPr> <w:rFonts w:ascii="ヒラギノ角ゴ ProN W3" w:eastAsia="ヒラギノ角ゴ ProN W3" w:hAnsi="ヒラギノ角ゴ ProN W3"/> </w:rPr> <w:t>Foobar.</w:t> </w:r>
If they differ, you want the one in
I find the 'w:ascii' and use the name. It still doesn't work. My code as follow:
run = paragraphs.add_run(namea1) run.bold = True #It works. run.font.size = Pt(19) #It works. run.font.name = "Adobe 楷体 Std R" #It doesn't work.
I will try other way to solve it.
Excited! You remind me!
<w:rFonts w:ascii="Adobe 楷体 Std R" w:eastAsia="Adobe 楷体 Std R" w:hAnsi="宋体" w:hint="eastAsia"/>
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.