How to embedded font inside the .pptx file

1.1k views Asked by At

I am creating a .pptx file using ASPOSE.Slides. I am trying to a embed font using Aspose, but it's not working because of some issues. Therefore i am searching for an alternative option to achieve the same functionality.

I want to embed my custom font in a .pptx file. Can you please provide suggestions for embedding fonts inside MS Power Point using Apache poi or other.

Please don't give the answers for static or local system.

4

There are 4 answers

0
Roman Haivaronski On

As it was stated above you can do it easily without Apache.

Official site

You can view/add/delete the font by accessing C:\Windows\Fonts

0
Mudassir On

@Bhagyashree,

Aspose.Slides allows you to embed the fonts inside presentation. I suggest you to please try using following sample code on your end to serve the purpose.

    String dataDir = Utils.getDataDir(AddEmbeddedFonts.class);
    Presentation pres=new Presentation(dataDir+"");
    IFontData[] allFonts = pres.getFontsManager().getFonts();
    IFontData[] embeddedFonts = pres.getFontsManager().getEmbeddedFonts();
    for (IFontData font : except(allFonts, embeddedFonts))
    {
        pres.getFontsManager().addEmbeddedFont(font,EmbedFontCharacters.All);
    }

    pres.save("saved.pptx",SaveFormat.Pptx);

Please feel free to share if there is any issue incurring on your end. I am working as Support developer/ Evangelist at Aspose.

0
Maxime COUTARD On

I don't know how to change it with Apache, but you can easily change it with powerpoint ...

0
kiwiwings On

With POI 4.1.0 (which will be released by approx. Feb. 2019), I've also added font embedding capabilities in Apache POI too. The provided methods are only the "half story", as you can't simply add .ttf/.otf files.

For the conversion of True-Type (.ttf) or Open-Type (.otf) fonts to Office-compatible EOT/MTX fonts, I'm using sfntly. The snftly classes aren't provided as maven artifacts yet and I don't like to import the whole chunk into POI nor release my repackaged version of googles code under my name, therefore you need to clone and adapt my example project.

For adding a MTX font stream to a slideshow (HSLF or XSLF, i.e. SlideShow is their common interface) you would call:

org.apache.poi.sl.usermodel.SlideShow.addFont(InputStream fontData)

For font subsetting, you would need the used codepoints, which can be extracted by:

org.apache.poi.sl.extractor.SlideShowExtractor.getCodepoints(String typeface, Boolean italic, Boolean bold)

For getting information about a MTX font data stream, there's a new helper class:

org.apache.poi.common.usermodel.fonts.FontHeader