We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

EmbedTrueTypeFonts=true causes large file after a modification in MS Word

Hi,

I embed a 100KB custom font in a generated file, it works but when the final user opens up that file in MS Word and saves any small modification (like a single letter), the file size increases a lot.

Reproduction: EmbedCustomFont.zip (79.9 KB)

The generated file is 101579 bytes, but if I open it in MS Word, add a single letter ‘a’ and save again, it becomes 1755596 bytes.
Original file: open-in-word-modify-and-check-size.docx (99.2 KB)

Re-saved file:open-in-word-modify-and-check-size.docx (1.7 MB)

The simplest reproduction is this:

static void Main(string[] args)
{
	var doc = new Document();
	doc.FontInfos.EmbedTrueTypeFonts = true;
	doc.FontInfos.EmbedSystemFonts = false;

	var builder = new DocumentBuilder(doc);
	builder.Writeln("Just a text");

	doc.Save($"open-in-word-modify-and-check-size.docx");
}

It seems like if EmbedSystemFonts = false; was not carried over to the MS Word save, even if my settings in Word are:

Using SaveSubsetFonts=true kind of solves it, but I want to fully embed only my custom font to allow changing text with all its character set.

Any idea on the cause and solution?

Thanks,

Word version: Microsoft® Word for Microsoft 365 MSO (16.0.14026.20294) 64-bit
Aspose.Words version: Both v19.10.0 and v21.6.0 tried

@dstj,

We have managed to reproduce the same problem on our end. For the sake of any correction in Aspose.Words API, we have logged this problem in our issue tracking system with ID WORDSNET-22423. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

1 Like

@dstj,

Regarding WORDSNET-22423, we have completed the analysis of this issue and concluded to close this issue with “not a bug” status. This looks more like a problem with Microsoft Word. In this case, MS Word treats fonts in Themes as used in document, despite the theme is not actually used anywhere in document’s text and thus embeds it into the document.

But, it is not necessary to change the document, you can just open and save it to observe the issue. Also, if you install the custom font in OS and edit document in MS Word, it will save this document with embedded fonts from Themes too.

To avoid this effect, you can set some system font in Themes, as the following:

doc.Theme.MajorFonts.Latin = "Arial";
doc.Theme.MinorFonts.Latin = "Arial";
1 Like

Ah! Interesting, the default values are Cambria and Calibri for a new Document(). I hadn’t realized that.

When creating a blank document from MS Word, it’s Calibri Light and Calibri, but it’s suffer from the same “problem”.

Thanks for figuring it now. I’ll force the theme fonts to a system font.

@dstj,

In case you have further inquiries or may need any help in future, please let us know by posting a new thread in Aspose.Words’ forum.