|
|
|
@ -17,7 +17,10 @@ namespace Avalonia.Media.Fonts |
|
|
|
/// <param name="source"></param>
|
|
|
|
public FontFamilyKey(Uri source) |
|
|
|
{ |
|
|
|
if (source == null) throw new ArgumentNullException(nameof(source)); |
|
|
|
if (source == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(source)); |
|
|
|
} |
|
|
|
|
|
|
|
if (source.AbsolutePath.Contains(".ttf")) |
|
|
|
{ |
|
|
|
@ -28,7 +31,17 @@ namespace Avalonia.Media.Fonts |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Location = source; |
|
|
|
if (source.AbsolutePath.Contains(".otf")) |
|
|
|
{ |
|
|
|
var filePathWithoutExtension = source.AbsolutePath.Replace(".otf", string.Empty); |
|
|
|
var fileNameWithoutExtension = filePathWithoutExtension.Split('.').Last(); |
|
|
|
FileName = fileNameWithoutExtension + ".otf"; |
|
|
|
Location = new Uri(source.OriginalString.Replace("." + FileName, string.Empty), UriKind.RelativeOrAbsolute); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Location = source; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -77,11 +90,20 @@ namespace Avalonia.Media.Fonts |
|
|
|
/// </returns>
|
|
|
|
public override bool Equals(object obj) |
|
|
|
{ |
|
|
|
if (!(obj is FontFamilyKey other)) return false; |
|
|
|
if (!(obj is FontFamilyKey other)) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (Location != other.Location) return false; |
|
|
|
if (Location != other.Location) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (FileName != other.FileName) return false; |
|
|
|
if (FileName != other.FileName) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
@ -94,7 +116,10 @@ namespace Avalonia.Media.Fonts |
|
|
|
/// </returns>
|
|
|
|
public override string ToString() |
|
|
|
{ |
|
|
|
if (FileName == null) return Location.PathAndQuery; |
|
|
|
if (FileName == null) |
|
|
|
{ |
|
|
|
return Location.PathAndQuery; |
|
|
|
} |
|
|
|
|
|
|
|
var builder = new UriBuilder(Location); |
|
|
|
|
|
|
|
@ -103,4 +128,4 @@ namespace Avalonia.Media.Fonts |
|
|
|
return builder.ToString(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|