Embedding font into Word files

Hi Team!

I would like to inquire about the possibilities to embedding custom font types into Word documents. My intention is to edit Word documents coming from different operating systems and in different languages and I would like the output Word document to look the same on every operating systems regardless of my custom font is installed on the system or not.

I have found a forum post about this where this had been logged as a feature request and later was resolved but I could not find any API documentation about it unfortunately.
https://forum.aspose.com/t/embedded-fonts-in-aspose-words/48667/2

I would be grateful if you could help me with some information, documentation or example code snippet.

Thank you in advance!

Best regards,
Tamas Boldizsar

@tamas.boldizsar This feature is already implemented. You can control font embedding into MS Word document using FontInfos.EmbedSystemFonts, FontInfos.EmbedTrueTypeFonts and FontInfos.SaveSubsetFonts properties. For example see the following code:

Document doc = new Document("C:\\Temp\\in.docx");

doc.FontInfos.EmbedSystemFonts = true;
doc.FontInfos.EmbedTrueTypeFonts = true;
doc.FontInfos.SaveSubsetFonts = false;

doc.Save("C:\\Temp\\out.docx");

But note, the fonts for embedding must be available in the environment where you process the document using Aspose.Words. Please see our documentation to learn where Aspose.Words looks for fonts and how to specify custom fonts location:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

1 Like

@alexey.noskov Thank you for your help!

1 Like