1

I am trying to make the "Scout Census" paragraph font size 48 and the "Statistics:" paragraph font size 22. Here is my attempt:

Tstyle = doc.styles['Normal']
font=Tstyle.font
font.name = "Nunito Sans"
font.size =Pt(48)
Title = doc.add_paragraph()
Title_format = Title.paragraph_format
Title_format.alignment=1
TRun= Title.add_run("Scout Census")
TRun.bold=True
doc.add_picture('Scouts_Logo_Stack_Black.png', width=Inches(4.0))

Hstyle = doc.styles['Normal']
Headfont=Hstyle.font
Headfont.name = "Nunito Sans"
Headfont.size =Pt(22)
Heading= doc.add_paragraph("Statistics:")
Heading.bold=True

When I run this code, both phrases have a font size of 22. Could someone explain to me why? I believe I have defined two different font objects, each with a different font size. So how can one override the other?

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
SkinUlcer
  • 11
  • 1
  • 1
    where do you tell the run/paragraph to use the derived /changed fonts? never used docx but I would assume something like `Title.style = TStyle` or `TRun.font = font` or `TRun.style = Tstyle` or ... something of that like is missing. – Patrick Artner Oct 28 '18 at 11:20
  • 1
    Possible duplicate of [Set paragraph font in python-docx](https://stackoverflow.com/questions/27884703/set-paragraph-font-in-python-docx) – Patrick Artner Oct 28 '18 at 11:29

0 Answers0