diff --git a/src/Avalonia.Visuals/Media/FontFamily.cs b/src/Avalonia.Visuals/Media/FontFamily.cs
index df933eb0ff..1cb20411ef 100644
--- a/src/Avalonia.Visuals/Media/FontFamily.cs
+++ b/src/Avalonia.Visuals/Media/FontFamily.cs
@@ -60,5 +60,50 @@ namespace Avalonia.Media
return Name;
}
+
+ ///
+ /// Parses a string.
+ ///
+ /// The string.
+ ///
+ ///
+ /// Specified family is not supported.
+ ///
+ public static FontFamily Parse(string s)
+ {
+ if (string.IsNullOrEmpty(s)) throw new ArgumentException("Specified family is not supported.");
+
+ var fontFamilyExpression = s.Split('#');
+
+ if (fontFamilyExpression.Length == 1)
+ {
+ return new FontFamily(s);
+ }
+
+ string familyName;
+
+ Uri source = null;
+
+ switch (fontFamilyExpression.Length)
+ {
+ case 1:
+ {
+ familyName = fontFamilyExpression[0];
+ break;
+ }
+ case 2:
+ {
+ source = new Uri(fontFamilyExpression[0], UriKind.RelativeOrAbsolute);
+ familyName = fontFamilyExpression[1];
+ break;
+ }
+ default:
+ {
+ throw new ArgumentException("Specified family is not supported.");
+ }
+ }
+
+ return new FontFamily(familyName, source);
+ }
}
}
diff --git a/src/Markup/Avalonia.Markup.Xaml/Converters/FontFamilyTypeConverter.cs b/src/Markup/Avalonia.Markup.Xaml/Converters/FontFamilyTypeConverter.cs
index 59742f8b12..9d03db5fa8 100644
--- a/src/Markup/Avalonia.Markup.Xaml/Converters/FontFamilyTypeConverter.cs
+++ b/src/Markup/Avalonia.Markup.Xaml/Converters/FontFamilyTypeConverter.cs
@@ -14,41 +14,7 @@ namespace Avalonia.Markup.Xaml.Converters
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
- var s = (string)value;
-
- if (string.IsNullOrEmpty(s)) throw new ArgumentException("Specified family is not supported.");
-
- var fontFamilyExpression = s.Split('#');
-
- if (fontFamilyExpression.Length == 1)
- {
- return new FontFamily(s);
- }
-
- string familyName;
-
- Uri source = null;
-
- switch (fontFamilyExpression.Length)
- {
- case 1:
- {
- familyName = fontFamilyExpression[0];
- break;
- }
- case 2:
- {
- source = new Uri(fontFamilyExpression[0], UriKind.RelativeOrAbsolute);
- familyName = fontFamilyExpression[1];
- break;
- }
- default:
- {
- throw new ArgumentException("Specified family is not supported.");
- }
- }
-
- return new FontFamily(familyName, source);
+ return FontFamily.Parse((string)value);
}
}
}
\ No newline at end of file
diff --git a/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github b/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github
index cdf46d7892..c066401445 160000
--- a/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github
+++ b/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github
@@ -1 +1 @@
-Subproject commit cdf46d7892def8a6ba29f12a9339147377f7cf5c
+Subproject commit c0664014455392ac221a765e66f9837704339b6f