Esempio n. 1
0
        private static void OptionallyParseTables(IReadOnlyDictionary <string, TrueTypeHeaderTable> tables, TrueTypeDataBytes data, TableRegister.Builder tableRegister)
        {
            // cmap
            if (tables.TryGetValue(TrueTypeHeaderTable.Cmap, out var cmap))
            {
                tableRegister.CMapTable = CMapTable.Load(data, cmap, tableRegister);
            }

            // hmtx
            if (tables.TryGetValue(TrueTypeHeaderTable.Hmtx, out var hmtxHeaderTable))
            {
                tableRegister.HorizontalMetricsTable = HorizontalMetricsTable.Load(data, hmtxHeaderTable, tableRegister);
            }

            // name
            if (tables.TryGetValue(TrueTypeHeaderTable.Name, out var nameHeaderTable))
            {
                // TODO: Not important
            }

            // os2

            // kern
            if (tables.TryGetValue(TrueTypeHeaderTable.Kern, out var kernHeaderTable))
            {
                tableRegister.KerningTable = KerningTable.Load(data, kernHeaderTable);
            }
        }
Esempio n. 2
0
        public void ShouldThrowExceptionWhenTableCouldNotBeFound()
        {
            var writer = new BinaryWriter();

            writer.WriteTrueTypeFileHeader();

            using (var stream = writer.GetStream())
            {
                var exception = Assert.Throws <InvalidFontTableException>(() => CMapTable.Load(new FontReader(stream)));

                Assert.Equal("cmap", exception.Table);
            }
        }
Esempio n. 3
0
        public void LoadFormat0()
        {
            var writer = new BinaryWriter();

            writer.WriteCMapTable(new[] {
                new Format0SubTable(0, PlatformIDs.Windows, 9, new byte[] { 0, 1, 2 })
            });

            CMapTable table = CMapTable.Load(writer.GetReader());

            Assert.Single(table.Tables.Where(x => x != null));

            Format0SubTable[] format0Tables = table.Tables.OfType <Format0SubTable>().ToArray();
            Assert.Single(format0Tables);
        }
Esempio n. 4
0
        public void LoadFormat0()
        {
            BinaryWriter writer = new BinaryWriter();

            writer.WriteCMapTable(new [] {
                new SixLabors.Fonts.Tables.General.CMap.Format0SubTable(0, PlatformIDs.Windows, 9, new byte[] { 0, 1, 2 })
            });

            CMapTable table = CMapTable.Load(writer.GetReader());

            Assert.Equal(1, table.Tables.Where(x => x != null).Count());

            Format0SubTable[] format0Tables = table.Tables.OfType <Format0SubTable>().ToArray();
            Assert.Equal(1, format0Tables.Length);
        }