Unicode mojibaking on Linux using custom TTF

Product: PDFTron.NET.x64 (W & L)

Product Version: 9.2.0.79374

Please give a brief summary of your issue:
When trying to use a custom TTF in order to allow accent marks and other special characters, it appears to be mojibaking only on Linux (see the assets).

Please describe your issue and provide steps to reproduce it:
0. Include the custom font

<ItemGroup>
    <None Remove="Assets\Fonts\PTSerif-Regular.ttf" />
    <Resource Include="Assets\Fonts\PTSerif-Regular.ttf">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Resource>
  </ItemGroup>
  1. Initialize PDFNet
  2. Create new PDFDoc
  3. Create TTF:
var fontPath = Path.Combine(Directory.GetCurrentDirectory(), "Assets", "Fonts", "PTSerif-Regular.ttf");
var unicodeFont = Font.CreateTrueTypeFont(pdfDoc, fontPath, true, false);
  1. Use the font (eb.CreateTextBegin(unicodeFont, 9); eb.CreateTextRun(text);)

Please provide a link to a minimal sample where the issue is reproducible:

Assets:
Linux:
Input text: “Certification text is here § Section é: I, Ðrake”, also is what’s shown in the logs when printing.
Output text: “Certification text is here§ Section é: I, Õrake”, also is what’s shown in the text-extract when printing.
image

Windows:
image

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


It seems you’re experiencing unicode mojibaking issues on Linux when using a custom TrueType Font (TTF) with PDFTron.NET. This problem often arises due to encoding mismatches or font embedding issues. Here’s how you can address this issue:

Some things you can try:

  • Ensure the TTF font file is correctly read and embedded in your application. Check if the font supports the necessary Unicode characters.

  • Verify that the correct character encoding is used throughout the process (UTF-8 is often preferred for Unicode support).

  • Test the rendering on different Linux distributions to see if the issue is specific to one environment.

  • Consider using PDFNet’s built-in font handling capabilities, which might better manage encoding and rendering.

  • Check if the font path is correctly resolved in your Linux environment, as path issues can sometimes lead to incorrect font usage.




Here are some resources that might help you:



Hopefully, this helps you solve your problem while you wait for a human to get back to you.

I’ll be happy to assist you zchampeau-tt and have some questions and suggestions for you.

If CreateUnicodeTextRun does not resolve your issue please attach the following here for me to investigate:

  1. Input file(s)
  2. Generated output file(s)
  3. Code and settings used to generate (2) from (1)
  4. Screenshots showing the output, and clearly indicating what you expected to get instead, and also clearly indicating the
    *Please include any necessary font files.

Switched to CreateUnicodeTextRun and it now works! I did also have to change the custom font I was using with another.
Edit: sorry I guess I have no idea how I replied to the wrong message twice

That is good to hear, is using a different font a good solution for you? If not, is it possible the font file is not valid or does not have a correct Unicode mapping?