<commit_before>﻿using System;

namespace SkiaSharp
{
	public class SKFontStyleSet : SKObject
	{
		[Preserve]
		internal SKFontStyleSet (IntPtr handle, bool owns)
			: base (handle, owns)
		{
		}

		public SKFontStyleSet ()
			: this (SkiaApi.sk_fontstyleset_create_empty (), true)
		{
		}

		protected override void Dispose (bool disposing)
		{
			if (Handle != IntPtr.Zero && OwnsHandle) {
				SkiaApi.sk_fontstyleset_unref (Handle);
			}

			base.Dispose (disposing);
		}

		public int Count => SkiaApi.sk_fontstyleset_get_count (Handle);

		public void GetStyle(int index, out SKFontStyle fontStyle, out string styleName)
		{
			fontStyle = new SKFontStyle ();
			using (var str = new SKString ()) {
				SkiaApi.sk_fontstyleset_get_style (Handle, index, fontStyle.Handle, str.Handle);
				styleName = (string)str;
			}
		}

		public SKTypeface CreateTypeface (int index)
		{
			return GetObject<SKTypeface> (SkiaApi.sk_fontstyleset_create_typeface (Handle, index));
		}

		public SKTypeface CreateTypeface (SKFontStyle style)
		{<commit_msg>First check to see if the index is in range<commit_after>﻿using System;

namespace SkiaSharp
{
	public class SKFontStyleSet : SKObject
	{
		[Preserve]
		internal SKFontStyleSet (IntPtr handle, bool owns)
			: base (handle, owns)
		{
		}

		public SKFontStyleSet ()
			: this (SkiaApi.sk_fontstyleset_create_empty (), true)
		{
		}

		protected override void Dispose (bool disposing)
		{
			if (Handle != IntPtr.Zero && OwnsHandle) {
				SkiaApi.sk_fontstyleset_unref (Handle);
			}

			base.Dispose (disposing);
		}

		public int Count => SkiaApi.sk_fontstyleset_get_count (Handle);

		public void GetStyle(int index, out SKFontStyle fontStyle, out string styleName)
		{
			fontStyle = new SKFontStyle ();
			using (var str = new SKString ()) {
				SkiaApi.sk_fontstyleset_get_style (Handle, index, fontStyle.Handle, str.Handle);
				styleName = (string)str;
			}
		}

		public SKTypeface CreateTypeface (int index)
		{
			if (index < 0 || index >= Count)
				throw new ArgumentOutOfRangeException ($"Index was out of range. Must be non-negative and less than the size of the set.", nameof (index));

			return GetObject<SKTypeface> (SkiaApi.sk_fontstyleset_create_typeface (Handle, index));
		}

		public SKTypeface CreateTypeface (SKFontStyle style)
		{
{'fraction_non_alphanumeric': 0.09786863853849499, 'fraction_numerical': 0.00043497172683775554, 'mean_word_length': 3.956896551724138, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, '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': '1535805', 'n_tokens_mistral': 877, 'n_tokens_neox': 759, 'n_words': 199}