Ejemplo n.º 1
0
        public static CMapTable Load(BinaryReader reader)
        {
            ushort version   = reader.ReadUInt16();
            ushort numTables = reader.ReadUInt16();

            var encodings = new EncodingRecord[numTables];

            for (int i = 0; i < numTables; i++)
            {
                encodings[i] = EncodingRecord.Read(reader);
            }

            // foreach encoding we move forward looking for th subtables
            var tables = new List <CMapSubTable>(numTables);

            foreach (IGrouping <uint, EncodingRecord> encoding in encodings.Where(x => x.PlatformID == PlatformIDs.Windows).GroupBy(x => x.Offset))
            {
                reader.Seek(encoding.Key, System.IO.SeekOrigin.Begin);

                ushort subTypeTableFormat = reader.ReadUInt16();

                switch (subTypeTableFormat)
                {
                case 0:
                    tables.AddRange(Format0SubTable.Load(encoding, reader));
                    break;

                case 4:
                    tables.AddRange(Format4SubTable.Load(encoding, reader));
                    break;
                }
            }

            return(new CMapTable(tables.ToArray()));
        }
Ejemplo n.º 2
0
 static string EncodingIDDescription(FieldViewModel ivm)
 {
     if (ivm.Parent is FieldViewModel parent)
     {
         EncodingRecord er         = (EncodingRecord)parent.Value;
         UInt16         platformID = er.platformID;
         UInt16         encodingID = er.encodingID;
         return(ItemContentHelper.EncodingIDText(platformID, encodingID));
     }
     return(null);
 }
Ejemplo n.º 3
0
        public void Read(TTFReader r, uint tableStart)
        {
            r.ReadInt(out this.version);
            r.ReadInt(out this.numTables);

            this.encodingRecords = new List <EncodingRecord>();
            for (int i = 0; i < this.numTables; ++i)
            {
                EncodingRecord er = new EncodingRecord();
                er.Read(r);
                this.encodingRecords.Add(er);
            }

            foreach (EncodingRecord rc in this.encodingRecords)
            {
                r.SetPosition(tableStart + rc.subtableOffset);

                ushort format = r.ReadUInt16();

                if (format == 0)
                {
                    if (this.format0 == null)
                    {
                        this.format0 = new List <Format0>();
                    }

                    Format0 f0 = new Format0();
                    f0.Read(r);
                    this.format0.Add(f0);
                }
                else if (format == 2)
                {
                    if (this.format2 == null)
                    {
                        this.format2 = new List <Format2>();
                    }

                    Format2 f2 = new Format2();
                    f2.Read(r);
                    this.format2.Add(f2);
                }
                else if (format == 4)
                {
                    if (this.format4 == null)
                    {
                        this.format4 = new List <Format4>();
                    }

                    Format4 f4 = new Format4();
                    f4.Read(r);
                    this.format4.Add(f4);
                }
                else if (format == 6)
                {
                    if (this.format6 == null)
                    {
                        this.format6 = new List <Format6>();
                    }

                    Format6 f6 = new Format6();
                    f6.Read(r);
                    this.format6.Add(f6);
                }
                else if (format == 8)
                {
                    if (this.format8 == null)
                    {
                        this.format8 = new List <Format8>();
                    }

                    Format8 f8 = new Format8();
                    f8.Read(r);
                    this.format8.Add(f8);
                }
                else if (format == 10)
                {
                    if (this.format10 == null)
                    {
                        this.format10 = new List <Format10>();
                    }

                    Format10 f10 = new Format10();
                    f10.Read(r);
                    this.format10.Add(f10);
                }
                else if (format == 12)
                {
                    if (this.format12 == null)
                    {
                        this.format12 = new List <Format12>();
                    }

                    Format12 f12 = new Format12();
                    f12.Read(r);
                    this.format12.Add(f12);
                }
                else if (format == 13)
                {
                    if (this.format13 == null)
                    {
                        this.format13 = new List <Format13>();
                    }

                    Format13 f13 = new Format13();
                    f13.Read(r);
                    this.format13.Add(f13);
                }
                else if (format == 14)
                {
                    if (this.format14 == null)
                    {
                        this.format14 = new List <Format14>();
                    }

                    Format14 f14 = new Format14();
                    f14.Read(r);
                    this.format14.Add(f14);
                }
            }
        }