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

Free Support Forum - aspose.com

Default font substitution does not use fontconfig configs for Linux when converting docx to pdf

Hi,

A default font substitution does not use fontconfig configs for Linux (Ubuntu 15.10 + mono 4.2.3.4) when converting docx to pdf (see the attached files WinFonts.docx and WinFonts.docx.pdf) that looks like a bug. The version Aspose.Words 16.11.0 for .NET 4.0 is used.
It should be noted that at the same time Aspose.Slides does the right substitution according to the configs when converting pptx to pdf (see the attached files WinFonts.pptx and WinFonts.pptx.pdf).

So, by fontconfig config, the font Arial should be substituted by “Liberation Sans” and “Times New Roman” - by “Liberation Serif”. But the sample code produces the pdf with Garuda and FreeSerif fonts.

Sample code:
{
var doc = new Aspose.Words.Document(“WinFonts.docx”);
doc.Save(“WinFonts.docx.pdf”);
}

Reference code for Aspose.Slides that works properly:
{
var presentation = (new Aspose.Slides.PresentationFactory()).ReadPresentation(“WinFonts.pptx”);
presentation.Save(“WinFonts.pptx.pdf”, Aspose.Slides.Export.SaveFormat.Pdf);
}

Best Regards,
Aleksey.

Hi Aleksey,

Thanks for your inquiry. Please use FontSettings.AddFontSubstitutes method to adds substitute (alternative) font names for given original font name as you are using here.

Please let us know if you have any more queries.

Hi Tahir,



the issue does not concern client font substitution through FontSettings.AddFontSubstitutes, but deals with default font substitution.



So, on my Linux (Ubuntu 15.10 + mono 4.2.3.4) the following code shows that the font “Liberation Sans” is used instead of Arial by .NET itself:

C#:

var fontName=“Arial”;

var fontFamily = new System.Drawing.FontFamily(fontName);

if (fontName==fontFamily.Name)

Console.WriteLine(“The font ‘{0}’ is directly used.”, fontName);

else

Console.WriteLine(“The font ‘{0}’ is auto substituted by ‘{1}’.”, fontName, fontFamily.Name);



The output of the code:

>> The font ‘Arial’ is auto substituted by ‘Liberation Sans’.



As I wrote above, Aspose.Slides works properly, apparently uses a similar code for valid default font substitution. But Aspose.Words does not - it uses some another default font substitution technique, not based on .NET one - that looks like a bug.



Best Regards,

Aleksey.

Hi Aleksey,

Thanks for your inquiry. Please read about font availability and substitution from following link.

Font Availability and Substitution

Could you please share "Liberation Sans" and "Liberation Serif" fonts here for further testing? We will investigate the issue on our side and provide you more information.

Hi, Tahir,



The code above shows using of .NET class FontFamily to get information about system font substitution. The mechanism is used by nearly all the applications for Linux including Aspose.Slides. Aspose.Words uses its own substitution mechanism and e.g. the font Arial is substituted by Garuda in contrast to “Liberation Sans” for system substitution one. The concrete font “Liberation Sans” does not matter.

The question is why Aspose.Words does not use the standard system substitution mechanism?

Could the product provide this variant of font substitution in a some future (may be in addition to existing one in the product already and providing a selection of mechanism)?



Best Regards,

Aleksey.

Hi Aleksey,

Thanks for your inquiry.

The font availability and substitution is well explained in this article. Please note that if a font is not present in the system but the substitute is found, Aspose.Words uses it as substitution.

The default list of substitutes for "Arial" font is {"Garuda", "FreeSans", "Liberation Sans", "DejaVu Sans"}. In your case, we suggest you please use FontSettings.SetFontSubstitutes method to get the desired output. Hope this helps you.

Hi Tahir,



I understand existing Aspose’s internal substitution mechanism and the method FontSettings.SetFontSubstitutes that serves to explicitly specify substitution font - and we have discussed it with you in a different topic - the method works. But the question of the current topic concerns the default substitution mechanism without using FontSettings.SetFontSubstitutes.



The question is why Aspose.Words does not use the standard system substitution mechanism, which is used by nearly all the applications for Linux, including Aspose.Slides (see sample code with FontFamily class above)?

Could the product provide this variant of font substitution in a some future (may be in addition to existing one in the product already and providing a selection of mechanism)?



Best Regards,

Aleksey.

Hi Aleksey,

Thanks for your inquiry. We have logged this problem in our issue tracking system as WORDSNET-14532. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-16496) have been fixed in this update