Free Support Forum -

How to apply custom font for Document

Hi there,

I’m using Apose Word to export my report. I want to apply my font for my report.
Following is my code to apply font :
                var fontSources = new ArrayList(FontSettings.GetFontsSources());
            <span style="color:green;">// Add a new folder source which will instruct Aspose.Words to search the following folder for fonts.</span>
            <span style="color:blue;">var</span> folderFontSource = <span style="color:blue;">new</span> <span style="color:#2b91af;">FolderFontSource</span>(<span style="color:#a31515;">@"App_Themes\VisionStylesheet\fonts\Bitstream Fonts\Fonts\Original Garamond\OpenType TTF Std\tt0863m_.ttf"</span>, <span style="color:blue;">true</span>);

            <span style="color:green;">// Add the custom folder which contains our fonts to the list of existing font sources.</span>

            <span style="color:green;">// Convert the Arraylist of source back into a primitive array of FontSource objects.</span>
            <span style="color:blue;">var</span> updatedFontSources = (<span style="color:#2b91af;">FontSourceBase</span>[])fontSources.ToArray(<span style="color:blue;">typeof</span>(<span style="color:#2b91af;">FontSourceBase</span>));

            <span style="color:green;">// Apply the new set of font sources to use.</span>
            <span style="color:#2b91af;">FontSettings</span>.SetFontsSources(updatedFontSources);</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">But when I view output. This font hasn't been applied in my report.</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">Please give me advances for this issue.</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">Many thanks for advances,</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">Thanks,</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">Hanh.</pre></div>
Hi Hanh,

Thanks for your inquiry. Please make sure that you're using latest version of Aspose.Words for .NET i.e. 15.6.0:

In case the problem still remains, please attach 1) your input Word document, 2) output PDF document and 3) Font file here for testing. We will investigate the issue on our end and provide you more information.

Best regards,

Hi you guys,

Thanks for your feedback. Right now, I’m using Apose Word version: It’s reason to my font cannot apply for my export. This’s right?

Hi Hanh,

Thanks for your inquiry. Well, the problem could be that Aspose.Words could not find required fonts on your machine during rendering. Please refer to the following articles to learn how Fonts work during rendering and if you get notifications of any font substitution during document save.

Best regards,