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

PdfSharpCore.Utils.FontResolver code cleanup, refactor #268

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion PdfSharpCore/Internal/FontFamilyModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace PdfSharpCore.Internal
public class FontFamilyModel
{
public string Name { get; set; }

public Dictionary<XFontStyle, string> FontFiles = new Dictionary<XFontStyle, string>();

public bool IsStyleAvailable(XFontStyle fontStyle)
Expand Down
38 changes: 38 additions & 0 deletions PdfSharpCore/Utils/FontFileInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using PdfSharpCore.Drawing;
using SixLabors.Fonts;

namespace PdfSharpCore.Utils
{
internal struct FontFileInfo
{
private FontFileInfo(string path, FontDescription fontDescription)
{
Path = path;
FontDescription = fontDescription;
}

public string Path { get; }
public FontDescription FontDescription { get; }
public string FamilyName => FontDescription.FontFamilyInvariantCulture;

public XFontStyle GuessFontStyle()
{
switch (FontDescription.Style)
{
case FontStyle.Bold:
return XFontStyle.Bold;
case FontStyle.Italic:
return XFontStyle.Italic;
case FontStyle.BoldItalic:
return XFontStyle.BoldItalic;
default:
return XFontStyle.Regular;
}
}
public static FontFileInfo Load(string path)
{
var fontDescription = FontDescription.LoadDescription(path);
return new FontFileInfo(path, fontDescription);
}
}
}
Loading