public void ShouldReturnNullWhenTableCouldNotBeFound() { var writer = new BigEndianBinaryWriter(); writer.WriteTrueTypeFileHeader(); using MemoryStream stream = writer.GetStream(); Assert.Null(VerticalHeadTable.Load(new FontReader(stream))); }
public void ShouldReturnDefaultValueWhenTableCouldNotBeFound() { var writer = new BigEndianBinaryWriter(); writer.WriteTrueTypeFileHeader(); using (System.IO.MemoryStream stream = writer.GetStream()) { var table = KerningTable.Load(new FontReader(stream)); Assert.NotNull(table); } }
public void ShouldThrowExceptionWhenTableCouldNotBeFound() { var writer = new BigEndianBinaryWriter(); writer.WriteTrueTypeFileHeader(); using (System.IO.MemoryStream stream = writer.GetStream()) { InvalidFontTableException exception = Assert.Throws <InvalidFontTableException>(() => CMapTable.Load(new FontReader(stream))); Assert.Equal("cmap", exception.Table); } }
public void ShouldReturnTableValues() { var writer = new BigEndianBinaryWriter(); writer.WriteTrueTypeFileHeader(); writer.WriteColrTable(new[] { new ColrGlyphRecord { Glyph = 1, Layers = { new ColrLayerRecord { Glyph = 10, Pallete = 1 }, new ColrLayerRecord { Glyph = 11, Pallete = 2 } } }, new ColrGlyphRecord { Glyph = 2, Layers = { new ColrLayerRecord { Glyph = 12, Pallete = 1 }, new ColrLayerRecord { Glyph = 13, Pallete = 2 } } } }); using (System.IO.Stream stream = TestFonts.TwemojiMozillaData()) { var reader = new FontReader(stream); ColrTable tbl = reader.GetTable <ColrTable>(); System.Span <Fonts.Tables.General.Colr.LayerRecord> layers = tbl.GetLayers(15); Assert.Equal(2, layers.Length); } }
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))); } }
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); } }