<commit_before>﻿using System;
using Xunit;
using System.IO;

namespace SkiaSharp.Tests
{
	public class SKFontManagerTest : SKTest
	{
		[SkippableFact]
		public void TestFontManagerMatchCharacter()
		{
			var fonts = SKFontManager.Default;
			var emoji = "🚀";
			var emojiChar = StringUtilities.GetUnicodeCharacterCode(emoji, SKTextEncoding.Utf32);
			using (var typeface = fonts.MatchCharacter(emojiChar))
			{
				if (IsLinux)
					Assert.Equal("Symbola", typeface.FamilyName);
				else if (IsMac)
					Assert.Equal("Apple Color Emoji", typeface.FamilyName);
				else if (IsWindows)
					Assert.Contains(typeface.FamilyName, new[] { "Segoe UI Emoji", "Segoe UI Symbol" });
			}
		}

		[SkippableFact]
		public void TestCreateDefault()
		{
			Assert.NotNull(SKFontManager.CreateDefault());
		}

		[SkippableFact]
		public void TestFamilyCount()
		{
			var fonts = SKFontManager.Default;
			Assert.True(fonts.FontFamilyCount > 0);

			var families = fonts.GetFontFamilies();
			Assert.True(families.Length > 0);
			Assert.Equal(fonts.FontFamilyCount, families.Length);
		}

		[SkippableFact]
		public void TestMatchFamily()
		{
			var fonts = SKFontManager.Default;

			var set = fonts.MatchFamily("Arial");
			Assert.NotNull(set);

			Assert.True(set.Count > 0);
		}

		[SkippableFact]
		public void TestMatchFamilyStyle()
		{
			var fonts = SKFontManager.Default;

			var tf = fonts.MatchFamily("Arial", SKFontStyle.Bold);
			Assert.NotNull(tf);

			Assert.Equal((int)SKFontStyleWeight.Bold, tf.FontWeight);
		}

		[SkippableFact]
		public void TestMatchTypeface()
		{
			var fonts = SKFontManager.Default;

			var normal = fonts.MatchFamily("Arial", SKFontStyle.Normal);
			Assert.NotNull(normal);
			Assert.Equal((int)SKFontStyleWeight.Normal, normal.FontWeight);

			var bold = fonts.MatchTypeface(normal, SKFontStyle.Bold);
			Assert.NotNull(bold);
			Assert.Equal((int)SKFontStyleWeight.Bold, bold.FontWeight);

			Assert.Equal(normal.FamilyName, bold.FamilyName);
		}

		[SkippableFact]
		public void NullWithMissingFile()
		{
			var fonts = SKFontManager.Default;

			Assert.Null(fonts.FromFile(Path.Combine(PathToFonts, "font that doesn't exist.ttf")));
		}

		[SkippableFact]
		public void TestFamilyName()
		{
			var fonts = SKFontManager.Default;

			using (var typeface = fonts.FromFile(Path.Combine(PathToFonts, "Roboto2-Regular_NoEmbed.ttf")))
			{
				Assert.Equal("Roboto2", typeface.FamilyName);
			}
		}

		[SkippableFact]
		public void CanReadData()
		{<commit_msg>macOS does not support matching typefaces.<commit_after>﻿using System;
using Xunit;
using System.IO;

namespace SkiaSharp.Tests
{
	public class SKFontManagerTest : SKTest
	{
		[SkippableFact]
		public void TestFontManagerMatchCharacter()
		{
			var fonts = SKFontManager.Default;
			var emoji = "🚀";
			var emojiChar = StringUtilities.GetUnicodeCharacterCode(emoji, SKTextEncoding.Utf32);
			using (var typeface = fonts.MatchCharacter(emojiChar))
			{
				if (IsLinux)
					Assert.Equal("Symbola", typeface.FamilyName);
				else if (IsMac)
					Assert.Equal("Apple Color Emoji", typeface.FamilyName);
				else if (IsWindows)
					Assert.Contains(typeface.FamilyName, new[] { "Segoe UI Emoji", "Segoe UI Symbol" });
			}
		}

		[SkippableFact]
		public void TestCreateDefault()
		{
			Assert.NotNull(SKFontManager.CreateDefault());
		}

		[SkippableFact]
		public void TestFamilyCount()
		{
			var fonts = SKFontManager.Default;
			Assert.True(fonts.FontFamilyCount > 0);

			var families = fonts.GetFontFamilies();
			Assert.True(families.Length > 0);
			Assert.Equal(fonts.FontFamilyCount, families.Length);
		}

		[SkippableFact]
		public void TestMatchFamily()
		{
			var fonts = SKFontManager.Default;

			var set = fonts.MatchFamily("Arial");
			Assert.NotNull(set);

			Assert.True(set.Count > 0);
		}

		[SkippableFact]
		public void TestMatchFamilyStyle()
		{
			var fonts = SKFontManager.Default;

			var tf = fonts.MatchFamily("Arial", SKFontStyle.Bold);
			Assert.NotNull(tf);

			Assert.Equal((int)SKFontStyleWeight.Bold, tf.FontWeight);
		}

		[SkippableFact]
		public void TestMatchTypeface()
		{
			if (IsMac)
				throw new SkipException("macOS does not support matching typefaces.");

			var fonts = SKFontManager.Default;

			var normal = fonts.MatchFamily("Arial", SKFontStyle.Normal);
			Assert.NotNull(normal);
			Assert.Equal((int)SKFontStyleWeight.Normal, normal.FontWeight);

			var bold = fonts.MatchTypeface(normal, SKFontStyle.Bold);
			Assert.NotNull(bold);
			Assert.Equal((int)SKFontStyleWeight.Bold, bold.FontWeight);

			Assert.Equal(normal.FamilyName, bold.FamilyName);
		}

		[SkippableFact]
		public void TestMatchTypefaceFromStream()
		{
			if (IsMac)
				throw new SkipException("macOS does not support matching typefaces.");

			var fonts = SKFontManager.Default;

			var typeface = fonts.FromFile(Path.Combine(PathToFonts, "Roboto2-Regular_NoEmbed.ttf"));
			Assert.Equal("Roboto2", typeface.FamilyName);

			var match = fonts.MatchTypeface(typeface, SKFontStyle.Bold);
			Assert.NotNull(match);
		}

		[SkippableFact]
		public void NullWithMissingFile()
		{
			var fonts = SKFontManager.Default;

			Assert.Null(fonts.FromFile(Path.Combine(PathToFonts, "font that doesn't exist.ttf")));
		}

		[SkippableFact]
		public void TestFamilyName()
		{
			var fonts = SKFontManager.Default;

			using (var typeface = fonts.FromFile(Path.Combine(PathToFonts, "Roboto2-Regular_NoEmbed.ttf")))
			{
				Assert.Equal("Roboto2", typeface.FamilyName);
			}
		}

		[SkippableFact]
		public void CanReadData()
		{
{'fraction_non_alphanumeric': 0.11954356094910343, 'fraction_numerical': 0.0028980257199782648, 'mean_word_length': 4.151119402985074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3376471', 'n_tokens_mistral': 2187, 'n_tokens_neox': 1820, 'n_words': 349}