dont crash when fonts are not found
This commit is contained in:
parent
652238f526
commit
f1b02e1a04
1 changed files with 5 additions and 1 deletions
|
@ -46,6 +46,7 @@ namespace Ryujinx.HLE.Font
|
||||||
};
|
};
|
||||||
|
|
||||||
int FontMemoryUsage = 0;
|
int FontMemoryUsage = 0;
|
||||||
|
|
||||||
foreach (byte[] data in FontData.Values)
|
foreach (byte[] data in FontData.Values)
|
||||||
{
|
{
|
||||||
FontMemoryUsage += data.Length;
|
FontMemoryUsage += data.Length;
|
||||||
|
@ -63,13 +64,16 @@ namespace Ryujinx.HLE.Font
|
||||||
public byte[] GetData(string FontName)
|
public byte[] GetData(string FontName)
|
||||||
{
|
{
|
||||||
string FontFilePath = Path.Combine(FontsPath, $"{FontName}.ttf");
|
string FontFilePath = Path.Combine(FontsPath, $"{FontName}.ttf");
|
||||||
|
|
||||||
if (File.Exists(FontFilePath))
|
if (File.Exists(FontFilePath))
|
||||||
{
|
{
|
||||||
return File.ReadAllBytes(FontFilePath);
|
return File.ReadAllBytes(FontFilePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new InvalidSystemResourceException($"Font \"{FontName}.ttf\" not found. Please provide it in \"{FontsPath}\".");
|
Console.WriteLine($"Font \"{FontName}.ttf\" not found. Please provide it in \"{FontsPath}\".");
|
||||||
|
|
||||||
|
return new byte[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue