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

Free Support Forum - aspose.com

Inherit MS Word Default FontFamily

In MS Word, you have the ability to setup your default font. This font will be selected by default every time you create a new Word Document. I am facing the issue that when creating a Word Document via Aspose, the default font is set as “Times New Roman” and not as the default font the user has setup in MS Word.

Is there any way for me to create a Word Document via Aspose, and inherit the Default font from MS Word?

@RuanVM,

Please ZIP and upload your sample Word document here for testing. Also, please share the code snippet that you are using to determine the default font by using Aspose.Words. We will then investigate the issue on our end and provide you more information.

I have uploaded 3 code snippets showing the following:

  1. How I create a Word Document using Aspose
  2. How the default font is selected as “Times New Roman”

I don’t have a code snippet where I determine the default font as that is part of my question. Please let me know if you require any additional information.

In the Zip is also 2 MS Word documents. 1 Generated by MS Word (font defaults to Freestyle Script), and another Generated by Aspose.Words (font defaults to Times New Roman).

Aspose_Docx_Generation.zip (226.3 KB)

@RuanVM,

Please try using the following code to get/set the default font name:

Document doc = new Document("E:\\Aspose_Docx_Generation\\MS_Word_Generated_Docx.docx");
Console.WriteLine(doc.Styles.DefaultFont.Name);

Hope, this helps.

Thank you for the reply, but that is not quite the answer I was looking for.

What I am currently trying to achieve is to determine what is the default font as setup in MS Word, runtime, while generating another Word Document using Aspose.Words. I am aware that you can set the default font, but at that point I don’t know what the user has setup their default font as in MS Word, so I don’t know what to set the default font to.

My actual question is:

Can you determine the user’s default font as setup in MS Word using Aspose.Words? Is this isolated settings in MS Word or does Aspose.Words have access to this information?

Many Thanks

@RuanVM,

We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-18537. We will further look into the details of this requirement and will keep you updated on the status of the linked issue.

@RuanVM,

If we understand your requirement correctly, you are actually referring to the default font defined in the Normal.dotm (located C:\Users\user_name\AppData\Roaming\Microsoft\Templates). So, you can either create a new document from the Normal.dotm itself or get the default font name from the Normal.dotm and set it in the newly created document. Hope, this helps.