Use two fonts in one table cell | Aspose.PDF for .NET | Default font is not working

i need show two fonts in a single cell, i use two TextFragment and set the font,it’s ok。
but If I set the default font(row or table),it will not work.
image.png (25.1 KB)

public void CreateDemo(string savepath)
{
Font FontA = FontRepository.FindFont(“SimSun”);
Font FontB = FontRepository.OpenFont(@“d:\SpecialFont.ttf”);

Document doc = new Document();
Page page = doc.Pages.Add();

Aspose.Pdf.Table tabcontent = new Aspose.Pdf.Table();
page.Paragraphs.Add(tabcontent);

tabcontent.ColumnWidths = "200";
tabcontent.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
tabcontent.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo(5,5,5,5);
tabcontent.DefaultCellPadding = margin;
        
//first row
var row = tabcontent.Rows.Add();
var cell = new Cell();
var sptxt = new TextFragment("页面Page");
sptxt.TextState.Font = FontA;
cell.Paragraphs.Add(sptxt);
row.Cells.Add(cell);

//second row
var row2 = tabcontent.Rows.Add();
var cell2 = new Cell();
var sptxt2 = new TextFragment("");
sptxt2.TextState.Font = FontB;
cell2.Paragraphs.Add(sptxt2);
row2.Cells.Add(cell2);

//third row
var row3 = tabcontent.Rows.Add();
var cell3 = new Cell();
sptxt = new TextFragment("页面Page");
sptxt2 = new TextFragment("");
sptxt.TextState.Font = FontA;
sptxt2.TextState.Font = FontB;
sptxt2.IsInLineParagraph = true;
cell3.Paragraphs.Add(sptxt);
cell3.Paragraphs.Add(sptxt2);
row3.Cells.Add(cell3);

//if set the default font,it will not work
//cell3.DefaultCellTextState.Font = FontA;
//row3.DefaultCellTextState.Font = FontA;
//tabcontent.DefaultCellTextState.Font = FontA;
doc.Save(savepath);

}

@epepep

Would you kindly share the other font file which you are using from a file path. Also, please share which language character are you adding inside table cell. We will test the scenario in our environment and address it accordingly.

@asad.ali
some characters is self made characters, created by windows tool(c:\windows\system32\eudcedit.exe).
SpecialFont.zip (11.7 KB)

@epepep

We were still unable to notice the issue in our environment while testing the scenario with Aspose.PDF for .NET 21.2. Would you kindly share the special random characters that you created using the Windows Tool. You can add them into a file and share that file in .zip format with us. This would help us testing the scenario accordingly.

@asad.ali
CreatePdf.zip (845 Bytes)
in vs2019,These characters are shown blank,It doesn’t matter
image.png (4.2 KB)
in notepad,it’s ok
image.png (31.3 KB)

@epepep

We apologize for the inconvenience being faced. But we were still unable to notice the issue. Would you please share the PDF file where special character text is added correctly and the other file where they are appearing as blocks if font is set as default font. We will further proceed accordingly.

@asad.ali
Please cancel this comment

 //tabcontent.DefaultCellTextState.Font = FontA;

@epepep

We used some special characters and tested the scenario as per the information provided by you. We obtained the attached output PDF.

2fontsissue.pdf (78.4 KB)

You can notice in the attached PDF that all text was rendered correctly. It is quite possible that issue is related to some specific special characters or symbols. That is why we asked for the PDF file in which characters were correctly displayed at your side so that we can use the same symbols at our end to test the scenario and share our feedback with you accordingly.

@asad.ali
Sorry to take so long to reply. this is the PDF file,do you want this file?
demo.pdf (189.5 KB)

    public void CreateDemo(string savepath)
    {
        Font FontA = FontRepository.FindFont("SimSun");
        Font FontB = FontRepository.OpenFont(@"d:\SpecialFont.ttf");
       
        Document doc = new Document();
        Page page = doc.Pages.Add();
        bool isexecute = true;
OnceMore:
        Aspose.Pdf.Table tabcontent = new Aspose.Pdf.Table();
        page.Paragraphs.Add(tabcontent);

        tabcontent.ColumnWidths = "200";
        tabcontent.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
        tabcontent.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
        Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo(5,5,5,5);
        tabcontent.DefaultCellPadding = margin;
        
        //first row
        var row = tabcontent.Rows.Add();
        var cell = new Cell();
        var sptxt = new TextFragment("页面Page");
        sptxt.TextState.Font = FontA;
        cell.Paragraphs.Add(sptxt);
        row.Cells.Add(cell);

        //second row
        var row2 = tabcontent.Rows.Add();
        var cell2 = new Cell();
        var sptxt2 = new TextFragment("");
        sptxt2.TextState.Font = FontB;
        cell2.Paragraphs.Add(sptxt2);
        row2.Cells.Add(cell2);

        //third row
        var row3 = tabcontent.Rows.Add();
        var cell3 = new Cell();
        sptxt = new TextFragment("页面Page");
        sptxt2 = new TextFragment("");
        sptxt.TextState.Font = FontA;
        sptxt2.TextState.Font = FontB;
        sptxt2.IsInLineParagraph = true;
        cell3.Paragraphs.Add(sptxt);
        cell3.Paragraphs.Add(sptxt2);
        row3.Cells.Add(cell3);

        //cell3.DefaultCellTextState.Font = FontA;
        //row3.DefaultCellTextState.Font = FontA;

        if (isexecute)
        {
            tabcontent.DefaultCellTextState.Font = FontA;
            isexecute = false;
            goto OnceMore;
        }
        
        doc.Save(savepath);
    }

@epepep

Thanks for sharing the sample file.

We have logged an issue as PDFNET-49590 in our issue tracking system for further investigation. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.