When generating presentations in Quarto, monospace font is very big

Viewed 291

I created a presentation in Quarto with code and outputted it to RevealJS and PPTX. The font size for code in RevealJS is sensible, but the font-size in PowerPoint is gigantic, so the same slide looks very different in RevealJS and PPTX.

Is there a configuration to reduce the font size for monospace fonts in PPTX?

1 Answers

I couldn't find a configuration, but I wrote a quick Python script that uses the python-pptx package to change the fonts. I run it after rendering the presentation.

I first set the font in the YAML as Consolas (to make it easier to find):

format: 
    pptx:
       reference-doc: templates/template.pptx
       monofont: "Consolas"
from pptx.util import Pt
from pptx import Presentation

prs = Presentation(path)

# text_runs will be populated with a list of strings,
# one for each text run in presentation
text_runs = []

for slide in prs.slides:
    for shape in slide.shapes:
        if not shape.has_text_frame:
            continue
        for paragraph in shape.text_frame.paragraphs:
            for run in paragraph.runs:
                if run.font.name == "Consolas":
                    run.font.size = Pt(12)

prs.save(new_path)
Related