'Python-docx library does not show the right font families

I'm trying to get the font families used in a docx file using python-docx library. The code snippet I'm using is as follows.

from docx import Document
doc = Document('cv4.docx')
for para in doc.paragraphs:
    for run in para.runs:
        print(run.font.name)

But this is not working. What I think is happening here is that the library only reads the parent paragraph and it does not read the nested paragraphs inside the runs. Can someone please suggest how to read all the paragraphs and runs inside those nested paragraphs to fetch the font families.

P.S. I have also tried doing it through xml parsing directly through the /word/document.xml file but it is not working as we have multiple docx file formats.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source