Exemple #1
0
        internal override string ConvertFromFontEncoding(PDFString str)
        {
            if (str == null)
            {
                return("");
            }

            loadCmapper();
            byte[]        data   = str.GetBytes();
            StringBuilder result = new StringBuilder(data.Length / 2 + 1);
            ushort        glyf;
            char          tmp;

            for (int i = 0; i < data.Length - 1; i += 2)
            {
                glyf = (ushort)(data[i] * 256 + data[i + 1]);
                tmp  = _toUnicode.GetChar(glyf);
                if (tmp == 0)
                {
                    string s = _toUnicode.GetLigature(glyf);
                    if (s == null)
                    {
                        tmp = _cidToGIDMap.GetChar(glyf);
                        if (tmp != 0)
                        {
                            result.Append(tmp);
                        }
                    }
                    else
                    {
                        result.Append(s);
                    }
                }
                else
                {
                    result.Append(tmp);
                }
            }

            return(result.ToString());
        }