Handle Font file

This commit is contained in:
Kevin Zhang 2021-08-06 17:04:19 +08:00
parent 2af29f8376
commit b86a2a8f5f

View file

@ -6,6 +6,7 @@ using Flow.Launcher.Infrastructure.Image;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using System.IO;
namespace Flow.Launcher.ViewModel
{
@ -60,14 +61,25 @@ namespace Flow.Launcher.ViewModel
Result = result;
Image = new LazyAsync<ImageSource>(
SetImage,
ImageLoader.DefaultImage,
() =>
{
OnPropertyChanged(nameof(Image));
});
SetImage,
ImageLoader.DefaultImage,
() =>
{
OnPropertyChanged(nameof(Image));
});
Glyph = Result.Glyph;
if (Result.Glyph.FontFamily.Contains('/'))
{
var fontPath = Result.Glyph.FontFamily;
Glyph = Path.IsPathRooted(fontPath) ? Result.Glyph : Result.Glyph with
{
FontFamily = Path.Combine(Result.PluginDirectory, fontPath)
};
}
else
{
Glyph = Result.Glyph;
}
}
Settings = settings;
@ -81,12 +93,12 @@ namespace Flow.Launcher.ViewModel
public string OpenResultModifiers => Settings.OpenResultModifiers;
public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip)
? Result.Title
: Result.TitleToolTip;
? Result.Title
: Result.TitleToolTip;
public string ShowSubTitleToolTip => string.IsNullOrEmpty(Result.SubTitleToolTip)
? Result.SubTitle
: Result.SubTitleToolTip;
? Result.SubTitle
: Result.SubTitleToolTip;
public LazyAsync<ImageSource> Image { get; set; }
@ -140,4 +152,4 @@ namespace Flow.Launcher.ViewModel
return Result.ToString();
}
}
}
}