Пример #1
0
        public ushort GetGlyphIndex(char ch)
        {
            if (ch < 32)
            {
                CMapEncodingRecord byteEncodingRecord = GetEncodingRecord(1, 0);
                if (byteEncodingRecord != null)
                {
                    return(byteEncodingRecord.GetGlyphIndex(ch));
                }
            }

            CMapEncodingRecord unicodeEncodingRecord = GetEncodingRecord(3, 1);

            if (unicodeEncodingRecord != null)
            {
                ushort result = unicodeEncodingRecord.GetGlyphIndex(ch);
                if (result != 0)
                {
                    return(result);
                }
            }

            for (int i = 0; i < _records.Count; ++i)
            {
                CMapEncodingRecord encRecord = _records[i];
                ushort             result    = encRecord.GetGlyphIndex(ch);
                if (result != 0)
                {
                    return(result);
                }
            }

            if (ch < 0xf000)
            {
                // Some fonts contains glyphs in Private Use Area.
                // Try to load from it.
                if (0xf000 + ch <= ushort.MaxValue)
                {
                    return(GetGlyphIndex((char)(0xf000 + ch)));
                }
            }

            return(0);
        }
Пример #2
0
        public override void Read(Reader reader, int offset, int length)
        {
            if (length < 0 || offset <= 0 || offset >= reader.Length)
            {
                throw new PDFWrongFontFileException();
            }

            reader.Position = offset;

            _version         = (UInt16)reader.ReadUint16();
            _numberSubtables = (UInt16)reader.ReadUint16();

            for (int i = 0; i < _numberSubtables; ++i)
            {
                CMapEncodingRecord rec = new CMapEncodingRecord();
                rec.Read(reader, offset);
                _records.Add(rec);
            }
        }