Fonts subset-embed in .docx are not carried over to the inserted main document after saved

We’re inserting a doc/docx (arial_embedfont.docx),which includes Arial font subset-embeded(*) inside, into a main document (mytemp.rtf). PDF generated with mainDoc.save(SaveFormat.PDF) does use Arial font from the arial_embedfont.docx. (1.pdf)
However when this maindocument is converted to byte array, and then save this copied byte array document as PDF format, the Arial font from arial_embed.docx is not available, resulting in strings showing up as unexpected fonts.

Is this expected? How can we use the Arial subset fonts available with the copied byte array document?

Code is like this:

        mainDoc = new Document(dataDir + "mytemp.rtf");
        DocumentBuilder builder = new DocumentBuilder(mainDoc);

        builder.moveToDocumentEnd();
        Document docToInsert = new Document(dataDir + "arial_embedfont.docx");

        builder.insertDocument(docToInsert, ImportFormatMode.USE_DESTINATION_STYLES);

        mainDoc.save(outDir + "1.pdf", SaveFormat.PDF);
        
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        mainDoc.save(out, SaveFormat.DOCX);  
        mainDoc.save(dataDir +"maindocSaved.docx",SaveFormat.DOCX);
        
        byte[] aa = out.toByteArray();
        Document docAA = new Document(new ByteArrayInputStream(aa));
        docAA.setFontSettings(fontSettings);
        
        docAA.save(outDir + "2.pdf", SaveFormat.PDF); 

1.pdf has Arial font embed.
2.pdf is not.
I noticed maindocSaved.docx does not have fonts embed inside anymore either.

(*1)
arial_embedfont.doc or .docx was saved with
Word option > Save > Embed fonts in the file checked and "“Embed only the characters used in the document”

testcase.zip (2.8 MB)

@kkawahar

We have tested the scenario using the shared code example and document and have not found the shared issue. Please check the attached output document. 2.pdf (71.1 KB)

Perhaps, you are facing this issue due to incorrect font settings at your end.

If you want to embed fonts in the Word document, you can use following code snippet.

FontInfoCollection fontInfos = mainDoc.getFontInfos();

fontInfos.setEmbedTrueTypeFonts(true);
fontInfos.setEmbedSystemFonts(true);
fontInfos.setSaveSubsetFonts(true);
mainDoc.save(MyDir +"maindoc.docx",SaveFormat.DOCX);