From f16423c41355c7a6c7bb8c200b7866bb8fdff82f Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 13 Nov 2018 14:32:50 -0800 Subject: [PATCH] fatal: Add font scaling support --- stratosphere/fatal/source/fatal_font.cpp | 8 +++++++- stratosphere/fatal/source/fatal_font.hpp | 1 + stratosphere/fatal/source/fatal_task_screen.cpp | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/stratosphere/fatal/source/fatal_font.cpp b/stratosphere/fatal/source/fatal_font.cpp index a832f3238..31b45833a 100644 --- a/stratosphere/fatal/source/fatal_font.cpp +++ b/stratosphere/fatal/source/fatal_font.cpp @@ -31,6 +31,7 @@ static u16 *g_fb = nullptr; static u32 (*g_unswizzle_func)(u32, u32) = nullptr; static u16 g_font_color = 0xFFFF; +static float g_font_sz = 16.0f; static u32 g_cur_x = 0, g_cur_y = 0; static PlFontData g_font; @@ -132,6 +133,11 @@ void FontManager::SetPosition(u32 x, u32 y) { g_cur_y = y; } +void FontManager::SetFontSize(float fsz) { + g_font_sz = fsz; + g_ft_err = FT_Set_Char_Size(g_face, 0, static_cast(g_font_sz * 64.0f), 96, 96); +} + void FontManager::AddSpacingLines(float num_lines) { g_cur_y += static_cast((static_cast(g_face->size->metrics.height) * num_lines) / 64.0f); } @@ -159,6 +165,6 @@ Result FontManager::InitializeSharedFont() { g_ft_err = FT_New_Memory_Face(g_library, reinterpret_cast(g_font.address), g_font.size, 0, &g_face); if (g_ft_err) return g_ft_err; - g_ft_err = FT_Set_Char_Size(g_face, 0, 8*64, 300, 300); + g_ft_err = FT_Set_Char_Size(g_face, 0, static_cast(g_font_sz * 64.0f), 96, 96); return g_ft_err; } \ No newline at end of file diff --git a/stratosphere/fatal/source/fatal_font.hpp b/stratosphere/fatal/source/fatal_font.hpp index a7622dc56..c0cb35456 100644 --- a/stratosphere/fatal/source/fatal_font.hpp +++ b/stratosphere/fatal/source/fatal_font.hpp @@ -31,6 +31,7 @@ class FontManager { static void SetFontColor(u16 color); static void SetPosition(u32 x, u32 y); + static void SetFontSize(float fsz); static void AddSpacingLines(float num_lines); static void PrintLine(const char *str); static void PrintFormatLine(const char *format, ...); diff --git a/stratosphere/fatal/source/fatal_task_screen.cpp b/stratosphere/fatal/source/fatal_task_screen.cpp index 1872a7222..1fffada4d 100644 --- a/stratosphere/fatal/source/fatal_task_screen.cpp +++ b/stratosphere/fatal/source/fatal_task_screen.cpp @@ -207,7 +207,7 @@ Result ShowFatalTask::ShowFatal() { FontManager::PrintFormatLine(u8"Firmware: %s (Atmosphère %u.%u.%u-%s)", GetFatalConfig()->firmware_version.display_version, CURRENT_ATMOSPHERE_VERSION, GetAtmosphereGitRevision()); - + /* Enqueue the buffer. */ framebufferEnd(&fb);