diff --git a/Ryujinx.HLE/Font/SharedFontManager.cs b/Ryujinx.HLE/Font/SharedFontManager.cs index 1c0ff95000..8dbae405d1 100644 --- a/Ryujinx.HLE/Font/SharedFontManager.cs +++ b/Ryujinx.HLE/Font/SharedFontManager.cs @@ -50,19 +50,22 @@ namespace Ryujinx.HLE.Font public byte[] GetData(string FontName) { string FontFilePath = Path.Combine(FontsPath, $"{FontName}.ttf"); - try + if (File.Exists(FontFilePath)) { return File.ReadAllBytes(FontFilePath); - } catch (FileNotFoundException e) + } + else { - throw new SystemResourceNotFoundException($"Font \"{FontName}.ttf\" not found. Please provide it in {FontsPath}", e); + throw new SystemResourceNotFoundException($"Font \"{FontName}.ttf\" not found. Please provide it in \"{FontsPath}\"."); } } public void MapFont(SharedFontType FontType, AMemory Memory, long Position) { + uint SharedMemoryAddressOffset = GetSharedMemoryAddressOffset(FontType); // TODO: find what are the 8 bytes before the font - Memory.WriteBytes(Position + GetSharedMemoryAddressOffset(FontType), FontEmbeddedPaths[FontType]); + Memory.WriteUInt64(Position + SharedMemoryAddressOffset - 8, 0); + Memory.WriteBytes(Position + SharedMemoryAddressOffset, FontEmbeddedPaths[FontType]); } public void PropagateNewMapFont(SharedFontType Type) @@ -97,11 +100,11 @@ namespace Ryujinx.HLE.Font (AMemory Memory, long Position, long Size) = ShMemPositions[ShMemPositions.Length - 1]; - for (SharedFontType Type = SharedFontType.JapanUsEurope; (int)Type < LoadedFonts.Length; Type++) + for (int Type = 0; Type < LoadedFonts.Length; Type++) { if (LoadedFonts[(int)Type] == 1) { - MapFont(Type, Memory, Position); + MapFont((SharedFontType)Type, Memory, Position); } } } @@ -140,7 +143,7 @@ namespace Ryujinx.HLE.Font public uint GetFontSize(SharedFontType FontType) { - return Convert.ToUInt32(FontEmbeddedPaths[FontType].Length); + return (uint)FontEmbeddedPaths[FontType].Length; } public uint GetSharedMemoryAddressOffset(SharedFontType FontType) @@ -156,9 +159,6 @@ namespace Ryujinx.HLE.Font return Pos; } - public int Count() - { - return FontEmbeddedPaths.Count; - } + public int Count => FontEmbeddedPaths.Count; } } diff --git a/Ryujinx.HLE/OsHle/Services/Pl/ISharedFontManager.cs b/Ryujinx.HLE/OsHle/Services/Pl/ISharedFontManager.cs index 7be59b63b8..b8447ac65c 100644 --- a/Ryujinx.HLE/OsHle/Services/Pl/ISharedFontManager.cs +++ b/Ryujinx.HLE/OsHle/Services/Pl/ISharedFontManager.cs @@ -102,14 +102,14 @@ namespace Ryujinx.HLE.OsHle.Services.Pl uint BufferPos = 0; uint Loaded = 0; - for (SharedFontType Type = SharedFontType.JapanUsEurope; (int)Type < Context.Ns.Font.Count(); Type++) + for (int Type = 0; Type < Context.Ns.Font.Count; Type++) { - BufferPos = AddFontToOrderOfPriorityList(Context, Type, BufferPos, out Loaded); + BufferPos = AddFontToOrderOfPriorityList(Context, (SharedFontType)Type, BufferPos, out Loaded); LoadedCount += Loaded; } Context.ResponseData.Write(LoadedCount); - Context.ResponseData.Write(Context.Ns.Font.Count()); + Context.ResponseData.Write(Context.Ns.Font.Count); return 0; } diff --git a/Ryujinx.HLE/Resource/SystemResourceNotFoundException.cs b/Ryujinx.HLE/Resource/SystemResourceNotFoundException.cs index 7473acf0c3..666bb98a1a 100644 --- a/Ryujinx.HLE/Resource/SystemResourceNotFoundException.cs +++ b/Ryujinx.HLE/Resource/SystemResourceNotFoundException.cs @@ -5,8 +5,8 @@ namespace Ryujinx.HLE.Resource public class SystemResourceNotFoundException: Exception { - public SystemResourceNotFoundException(string message, Exception inner) - : base(message, inner) + public SystemResourceNotFoundException(string message) + : base(message) { }