Hi there
When trying to convert a word document to a PDF, where the fonts used within the word document are not part of the underlying system, Aspose tries to find a suitable substitution font (as stated at https://docs.aspose.com/words/java/using-truetype-fonts/).
Code Snippet:
public static void convertToPdf(File inputFile, File outputFile) throws Exception {
try (FileInputStream fis = new FileInputStream(inputFile); FileOutputStream fos = new FileOutputStream(outputFile)) {
Document doc = new Document(fis);
doc.setWarningCallback(new HandleDocumentWarnings());
doc.save(fos, new PdfSaveOptions());
}
}
Warning callback is implemented as described in https://docs.aspose.com/words/java/manipulate-and-substitute-truetype-fonts/
Output for System 1
Font substitution: Font ‘Calibri’ has not been found. Using ‘Cousine’ font instead. Reason: first available font.
Font substitution: Font ‘Times New Roman’ has not been found. Using ‘Cousine’ font instead. Reason: first available font.
Output for System 2
Font substitution: Font ‘Calibri’ has not been found. Using ‘Symbol Neu’ font instead. Reason: first available font.
Font substitution: Font ‘Times New Roman’ has not been found. Using ‘Symbol Neu’ font instead. Reason: first available font.
Tested with Aspose Words 16.2 and 16.4.
Both systems have Ubuntu 14.04.4 LTS (server edition) with only the following three fonts package installed (see https://en.wikipedia.org/wiki/Croscore_fonts):
fonts-croscore
fonts-crosextra-caladea
fonts-crosextra-carlito
Questions:
-
How is “most suitable font” defined (point 4) [PANOSE?]? Is there a way to give hints to Aspose for finding a suitable font? I don’t use addFontSubstitutes because the font substitution would be checked right after Point 1, which is to early because embedded fonts would be omitted. I would expect that Carlito would be a suitable substitution for Calibri for example.
-
“First available font” doesn’t seem to be deterministic because resulting in different fonts on different systems. Is there a way that I can assure a “last” font option? Setting FontSettings.DefaultFontName would always use the default font instead of finding a more suitable one, thus not really a preferable solution. Font “Symbol” might always be a bad choice
A callback to allow specific fonts to be chosen dynamically as stated in https://docs.aspose.com/words/java/manipulate-and-substitute-truetype-fonts/ would be really great.
Kind regards and thanks
Stephan