Declined
Last Updated: 15 Oct 2019 17:38 by ADMIN
Chris
Created on: 08 Oct 2019 16:24
Category: PdfProcessing
Type: Bug Report
1
TryGetCharCode for OpenTypeFont uses wrong cmap and returns wrong charcode

I was working on some acroforms and wherever I needed a space I kept on getting a different letter (Ê). On debugging the problem seems to be in the TryGetCharCode function of OpenTypeFontSource

Version: 2019.3.917

Below is copy of function

public override bool TryGetCharCode(int unicode, out int charCode)
        {
            bool result = false;
            ushort glyphId;
            charCode = CMap.MISSING_GLYPH_ID;
            if (this.TryGetGlyphId(unicode, out glyphId))
            {
                ushort uCharCode = CMap.MISSING_GLYPH_ID;
                CMapTable table = this.CMap.GetCMapTable(3, 0);
                if (table != null)
                {
                    result = table.TryGetCharId(glyphId, out uCharCode);
                }

                table = this.CMap.GetCMapTable(1, 0);
                if (table != null)
                {
                    result = table.TryGetCharId(glyphId, out uCharCode);
                }

                charCode = uCharCode;

                return result;
            }

            return false;
        }

The font used has 2 cmap tables: one with platformid of 3 and encodingid of 1, the other with platformid 1 and encodingid 0. According to https://docs.microsoft.com/en-us/typography/opentype/spec/cmap platform id 3 and encoding 1 is correct for windows so not sure why the first call to getcmaptable looks for encodingid 0.

Second of all even if I change it to the following

CMapTable table = this.CMap.GetCMapTable(3, 1);

if there is a second cmap with platformid of 1 whatever the result of the call with regards to platformid 3, the result will be overridden

I can say that if I add some checks so that if the first call succeeds it doesn't attempt the 2nd I do get the expected behaviour in the pdf and get spaces

 

As a note the FontFamily property of the OpenTypeFontSource is "Arial"

1 comment
ADMIN
Georgi
Posted on: 15 Oct 2019 17:38

Hello Chris,

Thank you for reporting this issue and sharing your observations with us.

We have logged this in our feedback portal: CharCodes to glyph indices are incorrectly mapped when exporting TextBoxField with TrueType font and defined encoding, where you can subscribe to be notified for any status updates. The information you have provided is greatly appreciated and will help us with the implementation of the item. I have added notes in our internal item to make sure that your observations will be taken into account for the development. As a small token of appreciation, I have increased your Telerik points.

Since this item is duplicated with the related one, I will proceed with changing its status to Declined. However, I will update the content of the related item in case someone else encounters the same issue.

I will stay available in case any questions arise.

Regards,
Georgi
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.