public string Encode(string text)
    {
        // convert any characters that fall in the /Encoding /Differences array
        if (_differences != null && _differences.Elements.Count > 0)
        {
            var glyphMap = AdobeGlyfList.Instance;
            var chars    = text.ToCharArray().Select(ch => {
                if (_differences.Elements.Count > ch)
                {
                    var item = _differences.Elements[ch];
                    if (item is PdfName name)
                    {
                        return(glyphMap.Lookup(name.Value));
                    }
                    if (item is PdfInteger number)
                    {
                        return(((char)number.Value).ToString());
                    }
                }
                return(ch.ToString());
            });
            return(string.Concat(chars));
        }

        // if this font has a /ToUnciode CMAP then we will first resolve the text through it
        if (_cmap != null)
        {
            return(_cmap.Encode(text));
        }

        // fallback on just displaying the text
        return(text);
    }