From b86a2a8f5f42d7a23a7cb011ca58524f6b6646c9 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Fri, 6 Aug 2021 17:04:19 +0800 Subject: [PATCH] Handle Font file --- Flow.Launcher/ViewModel/ResultViewModel.cs | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs index ce4b23d21..c8664dc36 100644 --- a/Flow.Launcher/ViewModel/ResultViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultViewModel.cs @@ -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( - 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 Image { get; set; } @@ -140,4 +152,4 @@ namespace Flow.Launcher.ViewModel return Result.ToString(); } } -} +} \ No newline at end of file