Fix fonts not found when running via compressed (will not work in mac .app likely)
This commit is contained in:
@@ -17,8 +17,11 @@ namespace ReceiptPDFBuilder.ViewModels;
|
|||||||
class MainViewModel : BaseViewModel, IFontResolver
|
class MainViewModel : BaseViewModel, IFontResolver
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private string _baseDir;
|
||||||
|
|
||||||
public MainViewModel(IChangeViewModel viewModelChanger) : base(viewModelChanger)
|
public MainViewModel(IChangeViewModel viewModelChanger) : base(viewModelChanger)
|
||||||
{
|
{
|
||||||
|
_baseDir = Path.GetDirectoryName(Environment.ProcessPath) ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ChooseFolder()
|
public async void ChooseFolder()
|
||||||
@@ -48,11 +51,11 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
Console.WriteLine("Getting font {0}", faceName);
|
Console.WriteLine("Getting font {0}", faceName);
|
||||||
if (faceName == "Noto Sans JP")
|
if (faceName == "Noto Sans JP")
|
||||||
{
|
{
|
||||||
return File.ReadAllBytes("Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-Regular.ttf");
|
return File.ReadAllBytes(Path.Combine(_baseDir, "Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-Regular.ttf"));
|
||||||
}
|
}
|
||||||
if (faceName == "Noto Sans JP Bold")
|
if (faceName == "Noto Sans JP Bold")
|
||||||
{
|
{
|
||||||
return File.ReadAllBytes("Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-SemiBold.ttf");
|
return File.ReadAllBytes(Path.Combine(_baseDir, "Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-SemiBold.ttf"));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user