Search code examples
pythonpython-docx

get a list of typeface and sizes used in a docx


I am using Python docx 0.8.5

I can't seem to be able to figure out how to get a list of typeface and sizes used in a document There is a Font object, accessible on Run.font but I can't handle this problem.

Can somebody please point me to an example? Thanks


Solution

  • There is no "centralized authority" in a Word document of what Fonts have been used. You'll need to parse through the full document and detect them yourself. Runs are the right place to look, but you'll also need to check styles, both paragraph and character styles. Also, to be thorough, you'll need to check the document default font.