53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System.Linq;
 | 
						|
 | 
						|
namespace Dashboard.Drawing
 | 
						|
{
 | 
						|
    public class FontExtension : DrawExtension
 | 
						|
    {
 | 
						|
        private FontExtension() : base("DB_Font", Enumerable.Empty<DrawExtension>())
 | 
						|
        {
 | 
						|
        }
 | 
						|
 | 
						|
        public static readonly IDrawExtension Instance = new FontExtension();
 | 
						|
    }
 | 
						|
 | 
						|
    public interface IFont : IDrawResource
 | 
						|
    {
 | 
						|
        public string Family { get; }
 | 
						|
        public float Size { get; }
 | 
						|
        public FontWeight Weight { get; }
 | 
						|
        public FontSlant Slant { get; }
 | 
						|
        public FontStretch Stretch { get; }
 | 
						|
    }
 | 
						|
 | 
						|
    public struct NamedFont : IFont
 | 
						|
    {
 | 
						|
        public IDrawExtension Kind { get; } = Instance;
 | 
						|
 | 
						|
        public string Family { get; }
 | 
						|
        public float Size { get; }
 | 
						|
        public FontWeight Weight { get; }
 | 
						|
        public FontSlant Slant { get; }
 | 
						|
        public FontStretch Stretch { get; }
 | 
						|
 | 
						|
        public NamedFont(string family, float size, FontWeight weight = FontWeight.Normal,
 | 
						|
            FontSlant slant = FontSlant.Normal, FontStretch stretch = FontStretch.Normal)
 | 
						|
        {
 | 
						|
            Family = family;
 | 
						|
            Size = size;
 | 
						|
            Weight = weight;
 | 
						|
            Slant = slant;
 | 
						|
            Stretch = Stretch;
 | 
						|
        }
 | 
						|
 | 
						|
        private static readonly IDrawExtension Instance = new Extension();
 | 
						|
 | 
						|
        private class Extension : DrawExtension
 | 
						|
        {
 | 
						|
            public Extension() : base("DB_Font_Named", [FontExtension.Instance])
 | 
						|
            {
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |