I’m looking for a way to get the direct filename of the font used in a run through python-docx.
My goal is to make a script that pulls text from a docx file and dynamically draws it on an image using pillow, and python-docx modules. The hope is, with a script that can pull specific font files from the docx file itself, I can easily be able to replicate bold / italic / bold and italic font without too much hassle.
Currently I can iterate through the runs of a docx file super easily, but am having issues figuring out a good scripting method for determining which exact font file to use when given the run.font.name value.
What I currently have is below:
import docx doc = docx.document('/path/to/file') for paragraph in doc.paragraphs: for word in paragraph.runs: print('word_name: ' + word.font.name) >> word_name: Calibri