Oswald Light font not getting picked while adding SVG image to PDF

Hi, I am trying to add an SVG image in the PDF, but it seems to not add the Oswald Light font in one of the text.

I have tried to open the same SVG image in my browser and I have the font installed on my system(ubuntu 18), and it seems to render the font correctly, but when I try to do the same using aspose.pdf, it doesn’t render the font to the text embedded in the SVG file(Please see the attached SVG file {font_issue.zip (90.8 KB)}). I have also added the fonts in the zip file.

Here is my code:

final List fonts_list = new ArrayList<>( Arrays.asList("/usr/share/fonts");
com.aspose.pdf.Document.setLocalFontPaths(fonts_list); // fonts_list is an array of string, which contains the
//local path of the installed fonts.
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document();
com.aspose.pdf.Page page = pdfDocument.getPages().add();
page.setPageSize(670, 1200);
com.aspose.pdf.Image image = new com.aspose.pdf.Image();
image.setFileType(com.aspose.pdf.ImageFileType.Svg);
image.setImageStream(new ByteArrayInputStream(this.source.getBytes())); //source is a string type, and
//contains the attached SVG file in a string.
image.getMargin().setBottom(-3);
page.getParagraphs().add(image);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
pdfDocument.save(byteArrayOutputStream);

@wvlabelmaker

Thanks for contacting support.

We have tested the scenario in our environment with Aspose.PDF for Java 19.1 and were able to notice the issue which you have mentioned. For the sake of correction, we have logged it as PDFJAVA-38325 in our issue tracking system. We will further look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi Asad, thanks for the quick reply, Meanwhile this is getting resolved, is there any possible workaround?

@wvlabelmaker

You may convert SVG file into PDF using following code snippet as well:

final List fonts_list = new ArrayList<>( Arrays.asList(dataDir + "font_issue"));
com.aspose.pdf.Document.setLocalFontPaths(fonts_list);
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir + "font_issue.svg", new SvgLoadOptions()); 
pdfDocument.save(dataDir + "SVGtoPDF.pdf");

SVGtoPDF.pdf (14.7 KB)

Obtained output from above code snippet is also attached for your reference. You may check it and use this approach in case it resolves your issue.

The attached pdf file(attached above) also doesn’t seem to render the “Oswald Light” font correctly. Also, I have tried that you suggested, but it doesn’t seems to render the font correctly.
I have attached zip file which contains variations of four fonts(Montserrat, Oswald, OpenSans Condensed, Open Sans) that are also not getting picked up by Aspose.PDF.

Please find the attached zip file here (1.7 MB).

@wvlabelmaker

Thanks for further elaboration.

We have checked the output file in our environment and observed that the font was embedded into document but its rendering was looking different. If you convert the document into Word file, you will also be able to check the font name fontname.png (5.2 KB).

Nevertheless, we have logged this information along with the files which you have shared above and will consider it during investigation of the issue. As soon as some significant progress is made towards issue resolution, we will let you know. Please spare us little time.

We are sorry for the inconvenience.

@asad.ali would be really helpful if you could provide an ETA on the fixes.

@wvlabelmaker

Thanks for writing back.

Since the issue has been logged under free support model, it has low priority and will be resolved on first come first serve basis unlike the priority support where issues have high precedence. However, we have recorded you concerns and as soon as we are in position to share any reliable ETA we will let you know. Please spare us little time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFJAVA-38325) have been fixed in Aspose.PDF for Java 19.8.