forked from ArthurHub/HTML-Renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFontFamilyAdapter.cs
More file actions
51 lines (45 loc) · 1.47 KB
/
FontFamilyAdapter.cs
File metadata and controls
51 lines (45 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// "Therefore those skilled at the unorthodox
// are infinite as heaven and earth,
// inexhaustible as the great rivers.
// When they come to an end,
// they begin again,
// like the days and months;
// they die and are reborn,
// like the four seasons."
//
// - Sun Tsu,
// "The Art of War"
using System.Globalization;
using System.Linq;
using System.Windows.Markup;
using System.Windows.Media;
using TheArtOfDev.HtmlRenderer.Adapters;
namespace TheArtOfDev.HtmlRenderer.WPF.Adapters
{
/// <summary>
/// Adapter for WPF Font family object for core.
/// </summary>
internal sealed class FontFamilyAdapter : RFontFamily
{
/// <summary>
/// Default language to get font family name by
/// </summary>
private static readonly XmlLanguage _xmlLanguage = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag);
/// <summary>
/// the underline win-forms font.
/// </summary>
private readonly FontFamily _fontFamily;
/// <summary>
/// Init.
/// </summary>
public FontFamilyAdapter(FontFamily fontFamily)
{
_fontFamily = fontFamily;
}
/// <summary>
/// the underline WPF font family.
/// </summary>
public FontFamily FontFamily => _fontFamily;
public override string Name => _fontFamily.FamilyNames.TryGetValue(_xmlLanguage, out var name) ? name : _fontFamily.FamilyNames.FirstOrDefault().Value;
}
}