private void ReadCMAP_4_SubTable(ushort format, CMAPRecord rec, TrueTypeTableEntryList list, BigEndianReader reader)
        {
            //start of the subtable
            long pos = reader.Position - 2;

            CMAP_4_SubTable four = new CMAP_4_SubTable(format);
            int             len  = reader.ReadUInt16();

            reader.ReadUInt16();//skip language
            int segCount = reader.ReadUInt16() / 2;

            four.segCount = segCount;
            int searchRange = reader.ReadUInt16();

            four.entrySelector = reader.ReadUInt16();
            four.rangeShift    = reader.ReadUInt16() / 2;
            four.startCount    = new ushort[segCount];
            four.endCount      = new ushort[segCount];
            four.idDelta       = new short[segCount];
            four.idRangeOffset = new ushort[segCount];

            for (int i = 0; i < segCount; i++)
            {
                four.endCount[i] = reader.ReadUInt16();
            }

            reader.ReadUInt16();

            for (int i = 0; i < segCount; i++)
            {
                four.startCount[i] = reader.ReadUInt16();
            }

            for (int i = 0; i < segCount; i++)
            {
                four.idDelta[i] = reader.ReadInt16();
            }

            for (int i = 0; i < segCount; i++)
            {
                ushort val = reader.ReadUInt16();
                four.idRangeOffset[i] = (ushort)((val >> 1) & 0xffff);
            }

            List <ushort> glyphs = new List <ushort>();

            while (reader.Position < pos + len)
            {
                glyphs.Add(reader.ReadUInt16());
            }
            four.glyphids = glyphs.ToArray();
            rec.SubTable  = four;
        }
        private void ReadCMAP_0_SubTable(ushort format, CMAPRecord rec, TrueTypeTableEntryList list, BigEndianReader reader)
        {
            CMAP_0_SubTable zero = new CMAP_0_SubTable(format);

            zero.Length   = reader.ReadUInt16();
            zero.Language = reader.ReadUInt16();

            byte[] offsets = new byte[256];

            for (int i = 0; i < 256; i++)
            {
                offsets[i] = reader.ReadByte();
            }
            zero.GlyphOffsets = offsets;
            rec.SubTable      = zero;
        }
 private void ReadCMAP_12_SubTable(ushort format, CMAPRecord rec, TrueTypeTableEntryList list, BigEndianReader reader)
 {
 }
        private TrueTypeFontTable ReadCMAPTable(uint length, TrueTypeTableEntryList list, BigEndianReader reader)
        {
            SubTables.CMAPTable tbl  = new Scryber.OpenType.SubTables.CMAPTable(reader.Position);
            Version             vers = reader.ReadUShortVersion();
            ushort num = reader.ReadUInt16();

            tbl.NumberOfTables = num;
            tbl.TableVersion   = vers;
            List <SubTables.CMAPRecord> recs = new List <Scryber.OpenType.SubTables.CMAPRecord>();

            for (int i = 0; i < num; i++)
            {
                ushort     plat   = reader.ReadUInt16();
                ushort     enc    = reader.ReadUInt16();
                uint       offset = reader.ReadUInt32();
                CMAPRecord rec    = new CMAPRecord();
                rec.Encoding  = new CMapEncoding((CharacterPlatforms)plat, enc);
                rec.MapOffset = offset;

                recs.Add(rec);
            }

            foreach (CMAPRecord rec in recs)
            {
                reader.Position = tbl.FileOffset + rec.MapOffset;
                ushort format = reader.ReadUInt16();

                switch (format)
                {
                case (0):
                    ReadCMAP_0_SubTable(format, rec, list, reader);

                    break;

                case (2):
                    ReadCMAP_2_SubTable(format, rec, list, reader);
                    break;

                case (4):
                    ReadCMAP_4_SubTable(format, rec, list, reader);
                    break;

                case (6):
                    ReadCMAP_6_SubTable(format, rec, list, reader);
                    break;

                case (8):
                    ReadCMAP_8_SubTable(format, rec, list, reader);
                    break;

                case (10):
                    ReadCMAP_10_SubTable(format, rec, list, reader);
                    break;

                case (12):
                    ReadCMAP_12_SubTable(format, rec, list, reader);
                    break;

                default:
                    break;
                }
            }

            //TODO:Read the CMAP Records

            tbl.Records = new CMAPRecordList(recs);

            return(tbl);
        }