Forums

LibreOffice Fonts

I'm trying to install some fonts for use with LibreOffice. I'm providing a pptx template that already has these fonts and I'm using LibreOffice to convert the pptx to png. However, LibreOffice is not recognizing the fonts and is converting them, distorting the pptx. I tested this in my local macbook pro and it was working fine after installing the fonts. However, I'm assuming I'm installing the fonts wrong here.

I moved all the fonts to ~/.fonts and ran fc-cache -f -v

Is there anything else I need to do?

Thanks for the help.

Hmm, that should be everything you need to do. Do you see them when you run

fc-list : family style spacing

...in Bash? (That is the command, exactly as I pasted it above -- that confused me for a moment because it's an odd syntax for a Bash command.)

Yes, I also can see the following. These are all the fonts I'm trying to install. However, LibreOffice is just not using them at all in the conversion.

08:04 ~ $ fc-list | grep -i 'cairo\|tex gyre'
/home/gyousab3test/.fonts/Cairo-SemiBold.ttf: Cairo,Cairo SemiBold:style=SemiBold,Regular
/usr/share/fonts/truetype/dejavu/DejaVuMathTeXGyre.ttf: DejaVu Math TeX Gyre:style=Regular
/home/gyousab3test/.fonts/texgyretermes-bold.otf: TeX Gyre Termes:style=Bold
/home/gyousab3test/.fonts/Cairo-Bold.ttf: Cairo:style=Bold
/home/gyousab3test/.fonts/Cairo-Regular.ttf: Cairo:style=Regular
/home/gyousab3test/.fonts/Cairo-Black.ttf: Cairo,Cairo Black:style=Black,Regular

That is very perplexing. I've spent some time searching around to find out whether there is some extra step needed to add fonts to OpenOffice once you've installed them for the OS itself, but all of the forum threads I found simply suggested that you follow the steps you've already done, and finished with people saying things like "thanks, that worked for me", so that sounds like it should be enough.

What command are you using to do the conversion with LibreOffice? Perhaps there's something non-obvious there?

This is the python code I'm running:

        prs.save(modified_pptx_path)

        os.makedirs(output_png, exist_ok=True)
        subprocess.run(
            [
                "soffice", "--headless", "--convert-to", "png",
                "--outdir", output_png, modified_pptx_path
            ],
            check=True
        )

Again, I tested this on my local flask server on my macbook pro. Before I installed the fonts, it was distorting the conversion. After installing the fonts and seeing them in the mac fontbook app, it worked like it should. Just can't seem to replicate it on the pythonanywhere server unfortunately.

This is an example of the font distortion that pythonanywhere is doing when trying to convert with LibreOffice.

https://ibb.co/Z22hcwp <-- Distorted

https://ibb.co/51m1dyD <-- What the fonts should look like

Could you email us at support@pythonanywhere.com with a pptx file as simple as possible that we could try to convert and reproduce your problem?