Skip to content

Commit

Permalink
feat: [Skia] Load fonts from local path
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Jul 23, 2020
1 parent a62e332 commit feaec98
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Uno.UI/UI/Xaml/Controls/TextBlock/TextVisual.Skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.Collections.Generic;
using System.Text;
using Uno;
using Uno.UI.Xaml;
using Windows.Foundation;
using Windows.Storage;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;

Expand All @@ -18,7 +20,20 @@ internal class TextVisual : Visual

private static SKTypeface FromFamilyName(string name)
{
return SKTypeface.FromFamilyName(name);
if (name.StartsWith(XamlFilePathHelper.AppXIdentifier))
{
var path = new Uri(name).PathAndQuery;

var filePath = global::System.IO.Path.Combine(Windows.Application­Model.Package.Current.Installed­Location.Path, path.TrimStart('/').Replace('/', global::System.IO.Path.DirectorySeparatorChar));

var font = SKTypeface.FromFile(filePath);

return font;
}
else
{
return SKTypeface.FromFamilyName(name);
}
}

public TextVisual(Compositor compositor, TextBlock owner) : base(compositor)
Expand Down

0 comments on commit feaec98

Please sign in to comment.