Italic fonts not embedded in PDF export on extra bold fonts

When using some extra bold fonts, and exporting document to pdf, instead of using italic version of the font, it applies fake italic. For example if we are using font Nunito Sans Extrabold, and set Italic to true, in PDF the font name is ‘Nunito Sans Extrabold, Italic’ instead of ‘Nunito Sans Extrabold Italic’. When regular version of Nunito Sans, everything works as expected.

Fonts that the problem occurs on:
Nunito Extrabold,
Nunito Sans Extrabold.

Font files for both of these fonts were downloaded from Google Fonts.

Using Aspose Words 23.1 for Java.
Java version 17.0.6

Sample code to reproduce this:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
doc.setFontSettings(FontSettings.getDefaultInstance());
doc.getFontSettings().setFontsSources(fontSources);
builder.getFont().setItalic(true);
builder.getFont().setName("Nunito Extrabold");
builder.writeln("Text");
doc.save("result.pdf");

@ANDREA.FARRIS Unfortunately, I cannot reproduce the problem on my side. I have downloaded Nunito and Nunito Sans font families from here:
https://fonts.google.com/specimen/Nunito
https://fonts.google.com/specimen/Nunito+Sans
Unzip and put the fonts into C:\Temp\font folder. Then used the following code for testing:

Document doc = new Document();
doc.setWarningCallback(new FontSubstitutionWarningCollector());
DocumentBuilder builder = new DocumentBuilder(doc);
doc.setFontSettings(FontSettings.getDefaultInstance());
doc.getFontSettings().setFontsSources(new FontSourceBase[] {new FolderFontSource("C:\\Temp\\fonts", true)});
builder.getFont().setItalic(true);
builder.getFont().setName("Nunito Extrabold");
builder.writeln("Text");
doc.save("C:\\Temp\\out.pdf");

Here is the output PDF produced on my side: out.pdf (3.8 KB)

As I can see proper font is embedded into the document:

Important note, when you download the font from fonts.google.com there are variable fonts and static fonts, please make sure the static fonts are used, since Aspose.Words does not fully support variable fonts.

Also, there is no Nunito Extrabold Italic font name, there is Italic variant of Nunito Extrabold:

@alexey.noskov
The problem actually reproduced for you, but it is hard to notice. When the font is written like ‘Nunito Extrabold, Italic’ (word italic after a comma), the italic letters are not taken from the italic font file, but from a regular font file and the italic effect is generated. The generated ‘fake’ italic differs from the actual italic file.

Side by side comparison of how the fonts differ: image.png (2.6 KB)

Attaching a pdf of how it should actually be exported out correct.pdf (4.6 KB)

@ANDREA.FARRIS You should also set Bolt property to get the expected result:

Document doc = new Document();
doc.setWarningCallback(new FontSubstitutionWarningCollector());
DocumentBuilder builder = new DocumentBuilder(doc);
doc.setFontSettings(FontSettings.getDefaultInstance());
doc.getFontSettings().setFontsSources(new FontSourceBase[] {new FolderFontSource("C:\\Temp\\fonts", true)});
builder.getFont().setItalic(true);
builder.getFont().setBold(true);
builder.getFont().setName("Nunito Extrabold");
builder.writeln("Nunito Extrabold");
doc.save("C:\\Temp\\out.pdf");

out.pdf (4.6 KB)

@alexey.noskov
Then what should I do in this case:

Let’s take Museo sans 900 font (which actually has font weight of 700).
The bug mentioned before reproduces with this font, but if I set both bold and italic for it, the docx and pdf export differs, because word applies bold to this font.

Here’s a difference between pdf and docx export

Is it actually the expected behavior, needing to apply both bold and italic for extrabold fonts? Because MS Word doesn’t require to apply bold to use correct italic font.

@ANDREA.FARRIS
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-25845

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@alexey.noskov
Was issue WORDSNET-25845 fixed?

@ANDREA.FARRIS Yes, the issue is already resolved in the current codebase. The fix will be included into the next 23.10 version of Aspose.Words. We will be sure to let you know once it is released.

The issues you have found earlier (filed as WORDSNET-25845) have been fixed in this Aspose.Words for Java 23.10 update.