@@ -179,7 +179,7 @@ def _apply_style_definitions(
179179 _apply_table_style_definition (docx_doc , defn )
180180
181181
182- def _apply_paragraph_style_definition ( # noqa: C901, PLR0912
182+ def _apply_paragraph_style_definition ( # noqa: C901, PLR0912, PLR0915
183183 docx_doc : docx_document .Document ,
184184 defn : styles_mod .ParagraphStyleDefinition ,
185185) -> None :
@@ -205,6 +205,21 @@ def _apply_paragraph_style_definition( # noqa: C901, PLR0912
205205 font = style .font
206206 if defn .font is not None :
207207 font .name = defn .font
208+ # font.element is the <w:style> element; <w:rFonts> lives inside <w:rPr>.
209+ # We must search the nested <w:rPr> to locate it.
210+ rpr = font .element .find (qn ("w:rPr" ))
211+ r_fonts = rpr .find (qn ("w:rFonts" )) if rpr is not None else None
212+ if r_fonts is None :
213+ # Built-in styles may already have <w:rPr> but no <w:rFonts>;
214+ # create and insert it as the first child of <w:rPr>.
215+ if rpr is None :
216+ rpr = etree .SubElement (font .element , qn ("w:rPr" ))
217+ r_fonts = etree .SubElement (rpr , qn ("w:rFonts" ))
218+ rpr .insert (0 , r_fonts )
219+ r_fonts .set (qn ("w:ascii" ), defn .font )
220+ r_fonts .set (qn ("w:hAnsi" ), defn .font )
221+ r_fonts .attrib .pop (qn ("w:asciiTheme" ), None )
222+ r_fonts .attrib .pop (qn ("w:hAnsiTheme" ), None )
208223 if defn .font_size is not None :
209224 font .size = shared .Pt (defn .font_size )
210225 if defn .bold is not None :
0 commit comments