From e3851365374c02ceeddf203566eac80c85d25076 Mon Sep 17 00:00:00 2001 From: Thog Date: Mon, 6 Jan 2020 14:58:13 +0100 Subject: [PATCH] Fix missing system font error while installing for the first time --- Ryujinx.HLE/FileSystem/Content/ContentManager.cs | 6 +++--- Ryujinx.HLE/HOS/Font/SharedFontManager.cs | 16 +++++++++------- .../HOS/Services/Sdb/Pl/ISharedFontManager.cs | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Ryujinx.HLE/FileSystem/Content/ContentManager.cs b/Ryujinx.HLE/FileSystem/Content/ContentManager.cs index 98ac3738e9..c99502d14f 100644 --- a/Ryujinx.HLE/FileSystem/Content/ContentManager.cs +++ b/Ryujinx.HLE/FileSystem/Content/ContentManager.cs @@ -56,7 +56,7 @@ namespace Ryujinx.HLE.FileSystem.Content _device = device; } - public void LoadEntries() + public void LoadEntries(bool ignoreMissingFonts = false) { _contentDictionary = new SortedDictionary<(ulong, NcaContentType), string>(); _locationEntries = new Dictionary>(); @@ -154,7 +154,7 @@ namespace Ryujinx.HLE.FileSystem.Content TimeManager.Instance.InitializeTimeZone(_device); - _device.System.Font.Initialize(this); + _device.System.Font.Initialize(this, ignoreMissingFonts); } public void ClearEntry(long titleId, NcaContentType contentType, StorageId storageId) @@ -815,7 +815,7 @@ namespace Ryujinx.HLE.FileSystem.Content public SystemVersion GetCurrentFirmwareVersion() { - LoadEntries(); + LoadEntries(true); var locationEnties = _locationEntries[StorageId.NandSystem]; diff --git a/Ryujinx.HLE/HOS/Font/SharedFontManager.cs b/Ryujinx.HLE/HOS/Font/SharedFontManager.cs index c54c8194bc..546dd86c16 100644 --- a/Ryujinx.HLE/HOS/Font/SharedFontManager.cs +++ b/Ryujinx.HLE/HOS/Font/SharedFontManager.cs @@ -44,15 +44,15 @@ namespace Ryujinx.HLE.HOS.Font _fontsPath = Path.Combine(device.FileSystem.GetSystemPath(), "fonts"); } - public void Initialize(ContentManager contentManager) + public void Initialize(ContentManager contentManager, bool ignoreMissingFonts) { _fontData?.Clear(); _fontData = null; - EnsureInitialized(contentManager); + EnsureInitialized(contentManager, ignoreMissingFonts); } - public void EnsureInitialized(ContentManager contentManager) + public void EnsureInitialized(ContentManager contentManager, bool ignoreMissingFonts) { if (_fontData == null) { @@ -120,10 +120,12 @@ namespace Ryujinx.HLE.HOS.Font return info; } - else + else if(!ignoreMissingFonts) { throw new InvalidSystemResourceException($"Font \"{name}.ttf\" not found. Please provide it in \"{_fontsPath}\"."); } + + return new FontInfo(); } _fontData = new Dictionary @@ -136,7 +138,7 @@ namespace Ryujinx.HLE.HOS.Font { SharedFontType.NintendoEx, CreateFont("FontNintendoExtended") } }; - if (fontOffset > Horizon.FontSize) + if (fontOffset > Horizon.FontSize && !ignoreMissingFonts) { throw new InvalidSystemResourceException( $"The sum of all fonts size exceed the shared memory size. " + @@ -159,14 +161,14 @@ namespace Ryujinx.HLE.HOS.Font public int GetFontSize(SharedFontType fontType) { - EnsureInitialized(_device.System.ContentManager); + EnsureInitialized(_device.System.ContentManager, false); return _fontData[fontType].Size; } public int GetSharedMemoryAddressOffset(SharedFontType fontType) { - EnsureInitialized(_device.System.ContentManager); + EnsureInitialized(_device.System.ContentManager, false); return _fontData[fontType].Offset + 8; } diff --git a/Ryujinx.HLE/HOS/Services/Sdb/Pl/ISharedFontManager.cs b/Ryujinx.HLE/HOS/Services/Sdb/Pl/ISharedFontManager.cs index 4560d9545c..418c15f2c2 100644 --- a/Ryujinx.HLE/HOS/Services/Sdb/Pl/ISharedFontManager.cs +++ b/Ryujinx.HLE/HOS/Services/Sdb/Pl/ISharedFontManager.cs @@ -61,7 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl // GetSharedMemoryNativeHandle() -> handle public ResultCode GetSharedMemoryNativeHandle(ServiceCtx context) { - context.Device.System.Font.EnsureInitialized(context.Device.System.ContentManager); + context.Device.System.Font.EnsureInitialized(context.Device.System.ContentManager, false); if (context.Process.HandleTable.GenerateHandle(context.Device.System.FontSharedMem, out int handle) != KernelResult.Success) {