Change Font in a PowerPoint Presentation Using Aspose.Slides for Python

How we can manage fonts(Major and minor) in a ppt? And also I need to export them to thumbnail and PDF.
We can see that in PowerPoint there are many fonts. How can I set those fonts in aspose slides?
Sometimes it works for all formats(pptx, pdf, thumbnails). Sometimes not work for one or two filetypes (pdf or thumbnail or pptx) exports.
We have tried to change font by:

pres.master_theme.font_scheme.minor.latin_font = slides.FontData("Trebuchet MS")

but this does not work for me.

After I have loaded these fonts to a ppt then tried:

minor_font, major_font = "Trebuchet MS"
with slides.Presentation(font_ppt_path) as font_ppt:
    heading_font = [font for font in font_ppt.masters[0].presentation.fonts_manager.get_fonts() if str(font) == major_font][0]

    body_font = [font for font in font_ppt.masters[0].presentation.fonts_manager.get_fonts() if str(font) == minor_font][0]

    pres.master_theme.font_scheme.major.latin_font = heading_font
    pres.master_theme.font_scheme.minor.latin_font = body_font

for export we load the fonts this way:

slides.FontsLoader.load_external_fonts(base_dir + "presentations/fonts/")

is there any issue with the font folder?
is mandatory to install fonts in the system?

For docker deployment, the thumbnail export not working. Only work with Arial font.
Show me a working code example

Requirements:
Change the ppt font and export that to thumbnails and PDF format.
Aspose version: 22.12.0
Deployed as a Docker container

@anantutkpd,
Thank you for describing the issue.

Please note that the font set for the master theme will not be applied if a different font is specified for the text. The master theme fonts are only applied by default.

You can specify a default font for a text paragraph like this:

paragraph.paragraph_format.default_portion_format.latin_font = FontData("Trebuchet MS")

or specify the font for a text portion like this:

paragraph.portions[0].portion_format.latin_font = FontData("Trebuchet MS")

I hope this will help you.

Documents: Text Formatting

If the solutions do not work for you, please share the following:

  • sample presentation file
  • your actual output files (PPTX, PDF, images)
  • expected output presentation file created in PowerPoint
  • Dockerfile

Not if fonts are loaded using the methods of the FontsLoader class.

Then how can I change the theme font of a pptx?
Is there any option for that?

Than what is the use of this?

pres.master_theme.font_scheme.minor.latin_font = slides.FontData("Trebuchet MS")

@anantutkpd,
Your code snippets look correct, you can use the font_scheme.minor and font_scheme.major properties to change theme fonts. If you are encountering a problem with it, please share the data and information mentioned above.

This code line sets the Trebuchet MS font as the default font for the Body part of presentation slides.

Documents: Presentation Theme

This is not functional for me. I want change the theme font. Not for the paragraph. How can I obtain this

@anantutkpd,
To help you properly, we need to understand and reproduce the problem on our end. So we need the data and information I mentioned above.