예제 #1
0
        private void initFontEncoding(Type1Parser parser)
        {
            List <KeyValuePair <ushort, string> > charset = parser.GetCharset();

            if (charset != null)
            {
                for (int i = 0; i < charset.Count; ++i)
                {
                    char c = GlyfNames.GetChar(charset[i].Value);
                    if (!_charset.ContainsKey(c))
                    {
                        _charset.Add(c, (byte)charset[i].Key);
                    }
                }
            }
            else
            {
                for (byte i = 32; i < 255; ++i)
                {
                    char ch = Encoding.GetChar(i);
                    if (!_charset.ContainsKey(ch))
                    {
                        _charset.Add(ch, i);
                    }
                }
            }
        }
예제 #2
0
        internal FontEncoding(IPDFObject encoding)
        {
            if (encoding is PDFDictionary)
            {
                initBaseEncoding((encoding as PDFDictionary)["BaseEncoding"] as PDFName);
                PDFArray differences = (encoding as PDFDictionary)["Differences"] as PDFArray;

                if (differences != null)
                {
                    int current = 0;
                    for (int i = 0; i < differences.Count; ++i)
                    {
                        if (differences[i] is PDFNumber)
                        {
                            current = (int)(differences[i] as PDFNumber).GetValue();
                        }
                        else
                        {
                            if (differences[i] is PDFName)
                            {
                                string glyfName = (differences[i] as PDFName).GetValue();
                                if (current < _charset.Count)
                                {
                                    _charset[current] = GlyfNames.GetChar(glyfName);
                                }
                            }

                            current++;
                        }
                    }
                }
            }
            else
            {
                initBaseEncoding(encoding as PDFName);
            }
        }