Skip to content

Commit b86a2a8

Browse files
committed
Handle Font file
1 parent 2af29f8 commit b86a2a8

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Flow.Launcher.Infrastructure.Logger;
77
using Flow.Launcher.Infrastructure.UserSettings;
88
using Flow.Launcher.Plugin;
9+
using System.IO;
910

1011
namespace Flow.Launcher.ViewModel
1112
{
@@ -60,14 +61,25 @@ public ResultViewModel(Result result, Settings settings)
6061
Result = result;
6162

6263
Image = new LazyAsync<ImageSource>(
63-
SetImage,
64-
ImageLoader.DefaultImage,
65-
() =>
66-
{
67-
OnPropertyChanged(nameof(Image));
68-
});
69-
70-
Glyph = Result.Glyph;
64+
SetImage,
65+
ImageLoader.DefaultImage,
66+
() =>
67+
{
68+
OnPropertyChanged(nameof(Image));
69+
});
70+
71+
if (Result.Glyph.FontFamily.Contains('/'))
72+
{
73+
var fontPath = Result.Glyph.FontFamily;
74+
Glyph = Path.IsPathRooted(fontPath) ? Result.Glyph : Result.Glyph with
75+
{
76+
FontFamily = Path.Combine(Result.PluginDirectory, fontPath)
77+
};
78+
}
79+
else
80+
{
81+
Glyph = Result.Glyph;
82+
}
7183
}
7284

7385
Settings = settings;
@@ -81,12 +93,12 @@ public ResultViewModel(Result result, Settings settings)
8193
public string OpenResultModifiers => Settings.OpenResultModifiers;
8294

8395
public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip)
84-
? Result.Title
85-
: Result.TitleToolTip;
96+
? Result.Title
97+
: Result.TitleToolTip;
8698

8799
public string ShowSubTitleToolTip => string.IsNullOrEmpty(Result.SubTitleToolTip)
88-
? Result.SubTitle
89-
: Result.SubTitleToolTip;
100+
? Result.SubTitle
101+
: Result.SubTitleToolTip;
90102

91103
public LazyAsync<ImageSource> Image { get; set; }
92104

@@ -140,4 +152,4 @@ public override string ToString()
140152
return Result.ToString();
141153
}
142154
}
143-
}
155+
}

0 commit comments

Comments
 (0)