Serious bug?: fonts not embedded at all when converting to PDF

Hello,

I’m using Aspose.Words for Java on Mac OS X (running Lion 10.7.3). I’m finding that whenever I try to convert a file to PDF format, no fonts are embedded. Or, at least, very few are - for the most part, only the standard fonts ever get embedded - Times New Roman, Arial and Courier. Sometimes other fonts get embedded, but it seems completely random.

I’ve attached two files to show what I mean. The original .docx file (fontstest.docx) contains several fonts - Helvetica Neue, Courier New, Garamond, Didot, Myriad Pro Condensed, Cochin and Futura.

The PDF file (fontstest.pdf) was converted from the .docx file using Aspose.words. As soon as you open it, you will see that the fonts are completely wrong - most of the document is in Times New Roman, even though not a single character of the original used Times New Roman. According to File > Properties in Adobe Acrobat, the embedded files are Courier New, Myriad Pro and Times New Roman. All of the other fonts - Helvetica Neue, Garamond, Didot, Cochin and Futura - have been completely discarded. (In another test document, Myriad Pro was discarded, yet it’s included here - so it seems that there is definitely a bug making things act erratically.)

Both of these files were created on the same machine (that is, the PDF file was converted on the same machine on which the .docx file was created), with all of these fonts on the system the PDF was created on. What’s going on here? The code I’m using is straightforward:

Document doc = new Document(inputPath);
doc.updateFields();
doc.save(outputPath);

I’ve also tried:

Document doc = new Document(inputPath);
doc.updateFields();
PdfSaveOptions options = new PdfSaveOptions();
options.setEmbedFullFonts(true);
doc.save(outputPath, options);

But this makes no difference whatsoever. I’ve also tried setting the fonts folder using FontSettings, but with no joy (and besides, it is clearly embedding some of the fonts and not others, even though they are all in the system fonts folder).

What gives? I’ve tried converting a range of files - RTF files, .doc files, .docx files, .odt files - and get the same result every time: the fonts in the PDF file are always completely messed up, mostly missing. I’m going to have a lot of angry users if I ship using the Aspose converters without resolving this…

Many thanks for your help!

All the best,

Keith

Hi Keith,

Thanks for your inquiry and sorry for the delayed response. Could you please also attach your fonts here for testing? I will check the issue on my side and provide you more information. Moreover, I would suggest you please go through the following articles on How Aspose.Words Uses True Type Fonts during rendering to fixed page formats e.g. PDF:

https://docs.aspose.com/words/java/using-truetype-fonts/

Best Regards,

Hello,

Many thanks for your reply. All the fonts I’m using for testing, bar one, are part of the standard Mac OS X install, so you should just be able to test this out on any Mac. On a Mac, just create an RTF file that contains a range of different fonts that come with your machine (contained in /Library/Fonts) and try converting it to a PDF file.

Also, I’m not sure how the document you linked to helps - it states that if Aspose is having trouble finding the necessary fonts, you should point it to the current fonts location using FontSettings, but as mentioned in my first post, I had already tried that without any success. I’ve also had a user test this on a different Mac, and he found exactly the same problem.

The part of the document that explains what to do in case the formatting is wrong is a little unclear to me, too:

PROBLEM: The layout and fonts in the output document is different from the original.

SOLUTION: You are using Aspose.Words on Linux or Mac OS. The document uses fonts that are not present on your computer or Aspose.Words cannot locate fonts on your computer.Copy True Type font files from a Windows machine or install a True Type font package. Use the FontSettings class to specify the location of the font files.

I am using Mac OS, as I say, but the fonts the document uses are present on my computer (most of the fonts that I’m using which are failing are present on all Macs). Is this solution saying that Aspose can’t use Mac fonts but only Windows True Type fonts?

Many thanks for your help!

All the best,

Keith

Hi Keith,

Thanks for your inquiry.

Aspose.Words should be able to use any type of TrueType fonts, regardless of what OS they are used on. Could you please manually verify that the fonts required are found in the system fonts folder by navigating to there and checking the files. If they are all there, could you please zip them all up and attach the archive to this post?

We will look into this issue further for you.

Thanks,

Hi Adam,

Many thanks for your attention on this, much appreciated. I’d already checked the /Library/Fonts folder was fine (I’m used to supporting users with font problems seeing as OS X is notorious for font issues), but you can see that it’s intact from this screenshot

As I say, all of these fonts work fine in other applications, too. I do note that the fonts used in the document (the example problem document I attached to my first post) are scattered about a bit, in:
/Library/Fonts
/Library/Fonts/Microsoft
/System/Library/Fonts
But I have tried using FontSettings.setFontsFolders() to no avail:

FontSettings.setFontsFolders(new String[]{"/System/Library/Fonts", "/Library/Fonts"}, true);

I can’t zip up all of the fonts folders as they come to over a gigabyte in size, so I wouldn’t be able to send them to you. I have zipped up the fonts used in the sample document for sending to you, but unfortunately I don’t seem to be able to attach them. When I go to “Add/Update”, choose the .zip file and click on “Save”, nothing happens (the .zip file is 4MB). As I’m not sure of the legality of sharing the fonts publicly, I don’t want to upload them to my own server and make them publicly available. Is there an email address I can send them to?

Here is a screenshot of the font files, though (showing their file extensions):

The only two fonts that are appearing in the PDF okay are Courier New (which is a .ttf file) and the MyriadCond-Pro font (which is an .otf file). The other fonts are true-type, too, though, with the extension .ttc - could the file extension be the problem?

Thanks again!

All the best,

Keith

Hi Keith,

Thanks for this additional information.

Yes sorry I meant zip up only the fonts used in the document, not the entire font folder If you are having troubles attaching the archive here then you send the file directly to me by clicking the “Contact” button above this post of mine and clicking “Send e-mail”.

I will wait for your input files and then test further.

Thanks,

Hi Adam,

Thanks again for looking into this. I’ve just sent you an email with the fonts attached in a zip file - please let me know if it doesn’t come through.

All the best,
Keith

Hi Keith

Thanks for sending me the fonts and my apologises for the delay.

I can see that the WarningCallback produces five errors related to the fonts not being embedded.

  1. Helvetica Neue in your font pack is a “dfont” type. This appears to be a MacOS font and is probably not supported at the moment. I have logged a request to look into supporting this font type.
  2. Garamond in your font pack appears to be a zero byte length file with no extension. Since it is empty it is not used. Could you please verify this file is correct?
  3. Didot font is missing from your font pack.
  4. Cochin is a TrueTypeCollection font. I believe this is not yet supported. I have logged a request to look into this font type.
  5. Futura font is TTC, the same issue as above.

We will look into these issues for you and get back to you with some feedback. If I can help with anything else, please feel free to ask.

Thanks,

Hi,

Now it’s my turn to apologise for the late reply.

Many thanks for looking into this, I really appreciate it. Thank you, also, for logging the requests to look into the unsupported font types - I understand it might not be possible, but thanks for asking your devs to look at it, at least.

I’m not sure why Garamond is zero-length - strange. But it does appear with no extension on my machine (I must have forgotten to include Didot, sorry about that).

Anyway, it looks as though for my PDF-generation I will just have to warn users about the fact that not all fonts are supported for the time being, which is useful to know, at least.

Thanks again for the help!

All the best,

Keith

Hi Keith,

Thanks for the additional information

Sure, we will keep you informed of any developments regarding your issues. In the mean time alerting any customers who use these types of fonts is a good idea. You can use the IWarningCallback to be warned of font substitution happening when converting a document in your application: https://docs.aspose.com/words/java/manipulate-and-substitute-truetype-fonts/

If we can help with anything else, please feel free to ask.

Thanks,

Hi Keith,

TrueType fonts from your package are not used by
Aspose.Words because they are not intended for use on Windows platform.
We will improve Aspose.Words functionality so it will be able to use
fonts intended only for MacOS platform.

As for dfont fonts it is
an old MacOS font format and we probably will not support them in
nearest future. But there are tools that can convert dfont to ttf. For
example you could try free tools Fondu or DfontSplitter.

Thank you Adam for the information on providing users with font substitution warnings and Konstantin for improving Aspose.Words to use MacOS-specific fonts in future! Incredible service all around. Will you post a note to this thread in the future when Aspose.Words gets this functionality, or should I just look out for the release notes?

Anyway, thanks again, and have a great weekend!

All the best,

Keith

Hi
Keith,

Sure, we will keep you informed of any developments and let you know via this forum thread once your issues are resolved.

Best Regards,

The issues you have found earlier (filed as WORDSNET-6283) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hello,

I’m afraid this update has made things far, far worse. Not only are Mac TrueType fonts still not working properly, but now, instead of being substituted for a different font, complete gobbledegook is being output. Here is an image from one such file.

In earlier versions of Aspose.words, the font was at least substituted for Times, making it readable - here it is just a bunch of squares.

All you have to do to reproduce this issue, in fact, is to try converting the fontstest.docx file I included in my original post. Use Aspose.words for Java to convert that to a PDF file, and you will see that half of the characters are missing in the resulting PDF file.

I have attached a PDF file converted from the fontstest.docx I attached to my first post using the latest version of Aspose.Words for Java.

For now, I have had to revert to the previous version of Aspose.Words, seeing as the new one is entirely unusable for me.

Thanks for working on this!

All the best,

Keith

Hi
Keith,

Thanks for your inquiry and sorry for the delayed response.

While using the latest version of Aspose.Words i.e 11.5.0, I was unable to reproduce any such issue on my side. For your reference, I have attached the PDF (out.pdf) i.e. generated on my side and the output produced seems fine to me. Could you please double check if the problematic fonts are actually installed on your side? Also, you may want to specify PdfSaveOptions.EmbedFullFonts to be able to embed full font files into the resulting PDF document.

Best Regards,

Hi,

Many thanks for the reply. I started writing you a long email explaining who to reproduce the problem, and gong into detail about which types of fonts weren’t working. However, during testing, I realised why we are seeing different things, I think.

I have been opening the resulting PDF files in Apple’s own PDF viewer - Preview.app. In that, many of the fonts appear scrambled or the text appears entirely missing.

If you open the files in Adobe Acrobat, however, they look fine, and all the fonts and text are present.

There thus seems to be something about the way in which the fonts are embedded that means Preview.app cannot display them. Given that our users are Mac users, though, the vast majority of them will be opening their files in Preview.app and not in Adobe Acrobat, which means we are still left with a major problem - if the PDF files cannot be displayed in Preview.app, then we will be inundated with support requests from confused users, so the current converters aren’t workable for us.

I’d be very grateful if you could test your resulting PDF files in Preview and let me know if there’s anything I can do to ensure they show up fine there, or if there is something you can fix your end…

Thanks!

All the best,

Keith

Hi
Keith,

Thanks for the additional information and sorry for the delayed response. We are checking with this scenario and will get back to you as soon as possible.

Best Regards,

Great, thank you!

Keith

P.S. No doubt know this already, but it seems that your documentation pages have been reported as containing malware to Google Safe Browsing - if I try to access the Documentation section of your website using either the Safari or Camino web browsers, I get warnings at every page that the pages contain malware (both browsers use Google Safe Browing by default). It was working fine yesterday, so this is new.

Hi Keith,

Thanks for your inquiry.

Yes we are aware of this issue and it’s fixed already. Thank you for informing us. There was no real threat, just a small problem with our system which is fixed now.

Thanks,