public void LoadHead()
        {
            var writer = new BigEndianBinaryWriter();

            writer.WriteHeadTable(new HeadTable(
                                      HeadTable.HeadFlags.None,
                                      HeadTable.HeadMacStyle.Italic | HeadTable.HeadMacStyle.Bold,
                                      1024,
                                      new DateTime(2017, 02, 06, 07, 47, 00),
                                      new DateTime(2017, 02, 07, 07, 47, 00),
                                      new Bounds(0, 0, 1024, 1022),
                                      0,
                                      HeadTable.IndexLocationFormats.Offset16));

            var head = HeadTable.Load(writer.GetReader());

            Assert.Equal(HeadTable.HeadFlags.None, head.Flags);
            Assert.Equal(HeadTable.HeadMacStyle.Italic | HeadTable.HeadMacStyle.Bold, head.MacStyle);
            Assert.Equal(1024, head.UnitsPerEm);
            Assert.Equal(new DateTime(2017, 02, 06, 07, 47, 00), head.Created);
            Assert.Equal(new DateTime(2017, 02, 07, 07, 47, 00), head.Modified);
            Assert.Equal(0, head.Bounds.Min.X);
            Assert.Equal(0, head.Bounds.Min.Y);
            Assert.Equal(1024, head.Bounds.Max.X);
            Assert.Equal(1022, head.Bounds.Max.Y);
            Assert.Equal(0, head.LowestRecPPEM);
            Assert.Equal(HeadTable.IndexLocationFormats.Offset16, head.IndexLocationFormat);
        }
示例#2
0
        public void ShouldReturnNullWhenTableCouldNotBeFound()
        {
            var writer = new BigEndianBinaryWriter();

            writer.WriteTrueTypeFileHeader(new TableHeader("head", 0, 0, 0), new TableHeader("maxp", 0, 0, 0));

            writer.WriteHeadTable(new HeadTable(
                                      HeadTable.HeadFlags.None,
                                      HeadTable.HeadMacStyle.Italic | HeadTable.HeadMacStyle.Bold,
                                      1024,
                                      new DateTime(2017, 02, 06, 07, 47, 00),
                                      new DateTime(2017, 02, 07, 07, 47, 00),
                                      new Bounds(0, 0, 1024, 1022),
                                      0,
                                      HeadTable.IndexLocationFormats.Offset16));

            using (System.IO.MemoryStream stream = writer.GetStream())
            {
                Assert.Null(IndexLocationTable.Load(new FontReader(stream)));
            }
        }
示例#3
0
        public void ShouldThrowExceptionWhenMaximumProfileTableCouldNotBeFound()
        {
            var writer = new BigEndianBinaryWriter();

            writer.WriteTrueTypeFileHeader(new TableHeader("head", 0, 0, 0));

            writer.WriteHeadTable(new HeadTable(
                                      HeadTable.HeadFlags.None,
                                      HeadTable.HeadMacStyle.Italic | HeadTable.HeadMacStyle.Bold,
                                      1024,
                                      new DateTime(2017, 02, 06, 07, 47, 00),
                                      new DateTime(2017, 02, 07, 07, 47, 00),
                                      new Bounds(0, 0, 1024, 1022),
                                      0,
                                      HeadTable.IndexLocationFormats.Offset16));

            using (System.IO.MemoryStream stream = writer.GetStream())
            {
                InvalidFontTableException exception = Assert.Throws <InvalidFontTableException>(
                    () => IndexLocationTable.Load(new FontReader(stream)));

                Assert.Equal("maxp", exception.Table);
            }
        }