Fixed: loading fonts from embedded resource via the FontManager.RegisterFontFromEmbeddedResource method
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing;
|
||||
|
||||
namespace QuestPDF.UnitTests
|
||||
{
|
||||
public class FontManagerTests
|
||||
{
|
||||
[Test]
|
||||
public void LoadFontFromFile()
|
||||
{
|
||||
using var stream = File.OpenRead("Resources/FontContent.ttf");
|
||||
FontManager.RegisterFont(stream);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadFontFromEmbeddedResource()
|
||||
{
|
||||
FontManager.RegisterFontFromEmbeddedResource("QuestPDF.UnitTests.Resources.FontEmbeddedResource.ttf");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadFontFromEmbeddedResource_ShouldThrowException_WhenResourceIsNotAvailable()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
FontManager.RegisterFontFromEmbeddedResource("QuestPDF.UnitTests.WrongPath.ttf");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,4 +17,13 @@
|
||||
<ProjectReference Include="..\QuestPDF\QuestPDF.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\FontContent.ttf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<EmbeddedResource Include="Resources\FontEmbeddedResource.ttf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user