Hello,
we are using Aspose.PDF to convert an SVG file (read by Aspose.Svg) to PDF. Here is a sample app to reproduce the problem.
aspose-test-app.zip (412.6 KB)
The SVG file can be found in the attached application’s folder (image.svg).
In this SVG file, there are some shapes with custom fonts. If you look for font-family
in the .svg file, you will find that some text uses “Beaming” font, while another uses “Spiderman” font. Files for these custom fonts are also present in CustomFonts folder.
In code of the sample app, we are setting path to custom fonts folder according to Aspose.SVG API documentation:
// set custom fonts location
var configuration = new Configuration();
var userAgentService = configuration.GetService<IUserAgentService>();
var currentFontsLookupFolders = userAgentService.FontsSettings.GetFontsLookupFolders();
var newFontsLookupFolders = currentFontsLookupFolders.Append(Path.Combine(currentExecutingAssemblyPath, "CustomFonts")).ToArray();
userAgentService.FontsSettings.SetFontsLookupFolders(newFontsLookupFolders);
The goal is to use system/user fonts, as well as custom font files.
When you launch the sample app, select the destination folder and press the button, the PDF document will be created. You can notice that the shape on the right has the right font applied (Beaming), but the shape on the left does not (is uses Spiderman font).
The issue is that the Spiderman.ttf font is defined in the .SVG file as font-family: Spiderman, but this file’s (Spiderman.ttf) Title attribute (actual font family name) is THE AMAZING SPIDER-MAN:
image.jpg (129.3 KB)
Because of that, we need to define font names substitutions. I managed to do it for Aspose.Cells and Aspose.Words using FontConfigs.SetFontSubstitutes and Aspose.Words.Fonts.Fontsettings respecively, but I didn’t find any way to do it for Aspose.SVG and this SVG → PDF conversion with Aspose.PDF.
We cannot change the font-family names in .svg file - this is application-specific and defined by the user.
Can you please advise on how to provide font substitutions in this case?
Thank you for your help in advance!