public void LoadFormat1() { var writer = new BinaryWriter(); writer.WriteNameTable(new Dictionary <NameIds, string> { { NameIds.CopyrightNotice, "copyright" }, { NameIds.FullFontName, "fullname" }, { NameIds.FontFamilyName, "family" }, { NameIds.FontSubfamilyName, "subfamily" }, { NameIds.UniqueFontID, "id" }, { (NameIds)90, "other1" }, { (NameIds)91, "other2" } }, new List <string> { "lang1", "lang2" }); NameTable table = NameTable.Load(writer.GetReader()); Assert.Equal("fullname", table.FontName); Assert.Equal("family", table.FontFamilyName); Assert.Equal("subfamily", table.FontSubFamilyName); Assert.Equal("id", table.Id); Assert.Equal("copyright", table.GetNameById(NameIds.CopyrightNotice)); Assert.Equal("other1", table.GetNameById(90)); Assert.Equal("other2", table.GetNameById(91)); }
public void LoadFormat1() { var writer = new BigEndianBinaryWriter(); writer.WriteNameTable( new Dictionary <KnownNameIds, string> { { KnownNameIds.CopyrightNotice, "copyright" }, { KnownNameIds.FullFontName, "fullname" }, { KnownNameIds.FontFamilyName, "family" }, { KnownNameIds.FontSubfamilyName, "subfamily" }, { KnownNameIds.UniqueFontID, "id" }, { (KnownNameIds)90, "other1" }, { (KnownNameIds)91, "other2" } }, new List <string> { "lang1", "lang2" }); var table = NameTable.Load(writer.GetReader()); Assert.Equal("fullname", table.FontName(CultureInfo.InvariantCulture)); Assert.Equal("family", table.FontFamilyName(CultureInfo.InvariantCulture)); Assert.Equal("subfamily", table.FontSubFamilyName(CultureInfo.InvariantCulture)); Assert.Equal("id", table.Id(CultureInfo.InvariantCulture)); Assert.Equal("copyright", table.GetNameById(CultureInfo.InvariantCulture, KnownNameIds.CopyrightNotice)); Assert.Equal("other1", table.GetNameById(CultureInfo.InvariantCulture, 90)); Assert.Equal("other2", table.GetNameById(CultureInfo.InvariantCulture, 91)); }
public void ShouldThrowExceptionWhenTableCouldNotBeFound() { var writer = new BinaryWriter(); writer.WriteTrueTypeFileHeader(); using (var stream = writer.GetStream()) { var exception = Assert.Throws <InvalidFontTableException>(() => NameTable.Load(new FontReader(stream))); Assert.Equal("name", exception.Table); } }