We are downloading Noto Color Emoji fonts from https://fonts.google.com/selection. We are using it in our code to convert text to PDF using Aspose Words. Our code is as below -
FontSettings fontSettings = new FontSettings();
FontSourceBase emojisFont = new StreamFontSource() {
@Override
public InputStream openFontDataStream() throws Exception {
return new ByteArrayInputStream(NOTO_COLOR_EMOJI);
}
};
fontSettings.setFontsSources(new FontSourceBase[]{liberationSans, emojisFont});
fontSettings.getSubstitutionSettings().getFontConfigSubstitution().setEnabled(false);
fontSettings.getSubstitutionSettings().getFontNameSubstitution().setEnabled(false);
fontSettings.getSubstitutionSettings().getFontInfoSubstitution().setEnabled(false);
fontSettings.getSubstitutionSettings().getTableSubstitution().addSubstitutes("Segoe UI Emoji", "Noto Color Emoji");
Document rootDocument = new Document();
rootDocument.setFontSettings(fontSettings);
rootDocument.setWarningCallback(new IWarningCallback() {
@Override
public void warning(WarningInfo warningInfo) {
if (warningInfo.getWarningType() == WarningType.FONT_SUBSTITUTION) {
LOG.warn("Font Warning: " + warningInfo.getDescription());
}
}
});
...
Document documentToAppend = new Document(inputStream, new TextLoadOptions());
rootDocument.appendDocument(documentToAppend, ImportFormatMode.KEEP_SOURCE_FORMATTING);
...
rootDocument.save(outputStream, new PdfSaveOptions());
The text that we are appending to our document is
\uD83D\uDE42 \uD83D\uDE09 \uD83D\uDE01 \uD83D\uDE0D \uD83D\uDE0E \uD83D\uDE0F \uD83D\uDC4F \uD83D\uDC4C \uD83D\uDC4B \uD83D\uDC4D \uD83D\uDC4E
However, in the PDF, the font glyphs are not rendering.
If we repeat the test using Noto (Monochrome) Emojis available on https://fonts.google.com/selection, the font glyphs render correctly.
The two PDFs are attached.
Could you please help.
Thanks
response_color.pdf (8.0 KB)
response_monochrome.pdf (9.1 KB)