public void Should_Throw_For_Invalid_Custom_Font() { using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) { var fontManager = new FontManagerImpl(); Assert.Throws <InvalidOperationException>(() => fontManager.CreateGlyphTypeface( new Typeface("resm:Avalonia.Skia.UnitTests.Assets?assembly=Avalonia.Skia.UnitTests#Unknown"))); } }
public void Should_Create_Typeface_From_Fallback_Bold() { var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(new FontFamily($"A, B, Arial"), weight: FontWeight.Bold)); var skTypeface = glyphTypeface.Typeface; Assert.True(skTypeface.FontWeight >= 600); }
public void Should_Load_Nearest_Matching_Font() { using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) { var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(s_fontUri, FontWeight.Black, FontStyle.Italic)); var skTypeface = glyphTypeface.Typeface; Assert.Equal("Noto Mono", skTypeface.FamilyName); } }
public void Should_Load_Typeface_From_Resource() { using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) { var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(s_fontUri)); var skTypeface = glyphTypeface.Typeface; Assert.Equal("Noto Mono", skTypeface.FamilyName); } }
public void Should_Create_Typeface_For_Unknown_Font() { var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(new FontFamily("Unknown"))); var skTypeface = glyphTypeface.Typeface; Assert.Equal(SKTypeface.Default.FamilyName, skTypeface.FamilyName); Assert.Equal(SKTypeface.Default.FontWeight, skTypeface.FontWeight); Assert.Equal(SKTypeface.Default.FontSlant, skTypeface.FontSlant); }
public void Should_Create_Typeface_From_Fallback_Bold() { var fontManager = new FontManagerImpl(); //we need to have a valid font name different from the default one string fontName = fontManager.GetInstalledFontFamilyNames().First(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(new FontFamily($"A, B, {fontName}"), FontWeight.Bold)); var skTypeface = glyphTypeface.Typeface; Assert.Equal(fontName, skTypeface.FamilyName); Assert.True(skTypeface.FontWeight >= 600); }
public void Should_Create_Typeface_From_Fallback() { var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(new FontFamily("A, B, " + fontManager.GetDefaultFontFamilyName()))); var skTypeface = glyphTypeface.Typeface; Assert.Equal(SKTypeface.Default.FamilyName, skTypeface.FamilyName); Assert.Equal(SKTypeface.Default.FontWeight, skTypeface.FontWeight); Assert.Equal(SKTypeface.Default.FontSlant, skTypeface.FontSlant); }
public void Should_Load_Nearest_Matching_Font() { using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) { Direct2D1Platform.Initialize(); var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(s_fontUri, FontStyle.Italic, FontWeight.Black)); var font = glyphTypeface.DWFont; Assert.Equal("Noto Mono", font.FontFamily.FamilyNames.GetString(0)); } }
public void Should_Load_Typeface_From_Resource() { using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface)) { Direct2D1Platform.Initialize(); var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(s_fontUri)); var font = glyphTypeface.DWFont; Assert.Equal("Noto Mono", font.FontFamily.FamilyNames.GetString(0)); } }
public void Should_Load_Nearest_Matching_Font() { using (AvaloniaLocator.EnterScope()) { var assetLoaderType = typeof(TestRoot).Assembly.GetType("Avalonia.Shared.PlatformSupport.AssetLoader"); var assetLoader = (IAssetLoader)Activator.CreateInstance(assetLoaderType, (Assembly)null); AvaloniaLocator.CurrentMutable.Bind <IAssetLoader>().ToConstant(assetLoader); var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(new FontFamily(s_fontUri), FontWeight.Black, FontStyle.Italic)); var skTypeface = glyphTypeface.Typeface; Assert.Equal("Noto Mono", skTypeface.FamilyName); } }
public void Should_Create_Typeface_From_Fallback_Bold() { using (AvaloniaLocator.EnterScope()) { Direct2D1Platform.Initialize(); var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(new FontFamily("A, B, Arial"), weight: FontWeight.Bold)); var font = glyphTypeface.DWFont; Assert.Equal("Arial", font.FontFamily.FamilyNames.GetString(0)); Assert.Equal(SharpDX.DirectWrite.FontWeight.Bold, font.Weight); Assert.Equal(SharpDX.DirectWrite.FontStyle.Normal, font.Style); } }
public void Should_Load_Typeface_From_Resource() { using (AvaloniaLocator.EnterScope()) { Direct2D1Platform.Initialize(); var assetLoaderType = typeof(TestRoot).Assembly.GetType("Avalonia.Shared.PlatformSupport.AssetLoader"); var assetLoader = (IAssetLoader)Activator.CreateInstance(assetLoaderType, (Assembly)null); AvaloniaLocator.CurrentMutable.Bind <IAssetLoader>().ToConstant(assetLoader); var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(new FontFamily(s_fontUri))); var font = glyphTypeface.DWFont; Assert.Equal("Noto Mono", font.FontFamily.FamilyNames.GetString(0)); } }
public void Should_Create_Typeface_For_Unknown_Font() { using (AvaloniaLocator.EnterScope()) { Direct2D1Platform.Initialize(); var fontManager = new FontManagerImpl(); var glyphTypeface = (GlyphTypefaceImpl)fontManager.CreateGlyphTypeface( new Typeface(new FontFamily("Unknown"))); var font = glyphTypeface.DWFont; var defaultName = fontManager.GetDefaultFontFamilyName(); Assert.Equal(defaultName, font.FontFamily.FamilyNames.GetString(0)); Assert.Equal(SharpDX.DirectWrite.FontWeight.Normal, font.Weight); Assert.Equal(SharpDX.DirectWrite.FontStyle.Normal, font.Style); } }