Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace System.Drawing Font usage with SkiaSharp SKFont #70

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions Scryber.Common/Options/FontOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Scryber.Options
namespace Scryber.Options
{
public class FontOptions
{
Expand Down Expand Up @@ -30,17 +28,12 @@ public FontOptions()
}
}



public class FontRegistrationOption
{
public string Family { get; set; }

public System.Drawing.FontStyle Style { get; set; }
public string Style { get; set; }

public string File { get; set; }
}



}
1 change: 0 additions & 1 deletion Scryber.Common/Scryber.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="5.0.0" />
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Options\" />
Expand Down
1 change: 0 additions & 1 deletion Scryber.Components/Components/Component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Scryber.Native;
using Scryber.Styles;
using Scryber.Drawing;
Expand Down
1 change: 0 additions & 1 deletion Scryber.Components/Components/ContainerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Scryber.Styles;
using Scryber.Drawing;
using Scryber.Native;
Expand Down
2 changes: 0 additions & 2 deletions Scryber.Components/Components/PageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

using System;
using System.Collections.Generic;
using System.Text;
using Scryber.Native;
using System.Drawing;
using Scryber.Styles;
using Scryber.Resources;
using Scryber.Drawing;
Expand Down
1 change: 0 additions & 1 deletion Scryber.Components/Components/TextLiteral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Scryber.Styles;
using Scryber.Native;
using Scryber.Text;
Expand Down
1 change: 0 additions & 1 deletion Scryber.Components/Components/VisualComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using System.Collections.Generic;
using System.Text;
using Scryber.Native;
using System.Drawing;
using Scryber.Styles;
using Scryber.Resources;
using Scryber.Drawing;
Expand Down
1 change: 0 additions & 1 deletion Scryber.Components/Data/Base64Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Drawing;

namespace Scryber.Data
{
Expand Down
1 change: 0 additions & 1 deletion Scryber.Components/PDFRenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using Scryber.Drawing;
using Scryber.Styles;

Expand Down
1 change: 0 additions & 1 deletion Scryber.Components/_Interface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using System.Collections.Generic;
using System.Text;
using Scryber.Native;
using System.Drawing;
using Scryber.Drawing;
using Scryber.Components;
using Scryber.Layout;
Expand Down
6 changes: 6 additions & 0 deletions Scryber.Core.UnitTest/Binding/ExpressionBinding_Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using System.Threading.Tasks;
using System.Xml;
using Scryber.Html;
using System.Threading;
using System.Globalization;

namespace Scryber.Core.UnitTests.Binding
{
Expand Down Expand Up @@ -271,6 +273,8 @@ private class FunctionTest
[TestMethod]
public void AllExpressions_Test()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

var model = new
{
number = 20.7,
Expand Down Expand Up @@ -866,6 +870,8 @@ public void BindCalcExpressionRepeat()
[TestCategory("Binding")]
public void BindCalcAllFunctions()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

var model = new
{
number = 20.7,
Expand Down
9 changes: 3 additions & 6 deletions Scryber.Core.UnitTest/Configuration/SetConfig_Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,31 +151,28 @@ public void FontOptions_Test()
Assert.AreEqual(3, font.Register.Length, "There are not 3 registered fonts");

var family = "Segoe UI";
var style = System.Drawing.FontStyle.Regular;
var fileStem = "Mocks/Fonts/";
var fileExt = ".ttf";
var fileName = "segoeui";

//Segoe UI Regular
var option = font.Register[0];
Assert.AreEqual(family, option.Family);
Assert.AreEqual(style, option.Style);
Assert.IsNull(option.Style);
Assert.AreEqual(fileStem + fileName + fileExt, option.File);

// Segoe UI Bold
option = font.Register[1];
style = System.Drawing.FontStyle.Bold;

Assert.AreEqual(family, option.Family);
Assert.AreEqual(style, option.Style);
Assert.AreEqual("Bold", option.Style);
Assert.AreEqual(fileStem + fileName + "b" + fileExt, option.File);

// Segoe UI Bold
option = font.Register[2];
style = System.Drawing.FontStyle.Italic;

Assert.AreEqual(family, option.Family);
Assert.AreEqual(style, option.Style);
Assert.AreEqual("Italic", option.Style);
Assert.AreEqual(fileStem + fileName + "i" + fileExt, option.File);

ConfigClassCleanup();
Expand Down
14 changes: 7 additions & 7 deletions Scryber.Core.UnitTest/Drawing/PDFFont_Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,14 @@ public void GetDrawingStyle_Test()
PDFUnit size = 12;
PDFFont target = new PDFFont(family, size);

System.Drawing.FontStyle actual;

SkiaSharp.SKFontStyle actual;
actual = target.GetDrawingStyle();
Assert.AreEqual(System.Drawing.FontStyle.Regular, actual);
Assert.AreEqual(SkiaSharp.SKFontStyle.Normal, actual);

target.FontStyle = FontStyle.Italic | FontStyle.Bold;
target.FontStyle = FontStyle.BoldItalic;
actual = target.GetDrawingStyle();
Assert.AreEqual(System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic, actual);
Assert.AreEqual(SkiaSharp.SKFontStyle.BoldItalic, actual);

}

Expand All @@ -323,8 +323,8 @@ public void GetDrawingStyle_Test()
public void GetDrawingStyle_Test1()
{
FontStyle fontStyle = FontStyle.Bold;
System.Drawing.FontStyle expected = System.Drawing.FontStyle.Bold;
System.Drawing.FontStyle actual;
SkiaSharp.SKFontStyle expected = SkiaSharp.SKFontStyle.Bold;
SkiaSharp.SKFontStyle actual;
actual = PDFFont.GetDrawingStyle(fontStyle);
Assert.AreEqual(expected, actual);
}
Expand Down
Loading