Text with CJK doesn't use font requested, depending on text

This is really weird but depending on text I’m trying to put into PDF, it may or may not use font I asked. So what I get is a PDF file where some CJK text is one font and and some in another event though I used same font. The only work around I found is to use TextFragmentAbsorber and loop though each part of PDF and reset the font again. That actually works but takes long time and requires you to save PDF first.

I cannot tell you exactly what characters cause problems but I know it is something in CJK range. Here is my code.

Thank you

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();

        var fromFragment = new TextFragment(txtWriteToPDF.Text);

        Aspose.Pdf.Page page = doc.Pages.Add();
        fromFragment.TextState.Font = FontRepository.FindFont("SimSun"); // <---  This works only sometimes



        TextFragmentAbsorber absorber = new TextFragmentAbsorber();

        foreach (TextFragment textFragment in absorber.TextFragments)

            textFragment.TextState.Font = FontRepository.FindFont("SimSun"); // <---  This fixes it



I tried the above code snippet with two string values and the font was applied for both strings. Please explain if I misunderstood something. What version of the library are you using?

//string txtWriteToPDF_Text = "some text CJK another some text";
string txtWriteToPDF_Text = "CJK";
var doc = new Aspose.Pdf.Document();

var fromFragment = new TextFragment(txtWriteToPDF_Text); 

That is the weird thing. If you have very specific characters, it doesn’t work. It does work fine with 85% of text.
I did my best to try to track down specific character and it seems when this one is present, fonts are not applied:

Unicode Character “ ” (U+2005)

I cannot type it but copy and paste for original text.

I would be happy to show over zoom call, if you do such things.


Same happens with some emjoi. Example: :heart:

Thank you, you have identified the cause.
With string

string txtWriteToPDF_Text = "some text \u2005 another some text"; // not set for this.
//string txtWriteToPDF_Text = "some text another some text"; // set for this string.

I reproduced the problem.

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): PDFNET-54460

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.