diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index 4469909548..387ca9cb18 100644 --- a/binaries/data/config/default.cfg +++ b/binaries/data/config/default.cfg @@ -190,6 +190,7 @@ server.port = "8000" ; Use a free port on your machine. server.threads = "6" ; Enough for the browser's parallel connection limit [console] +font = "mono-10" history.size = 200 [hotkey] diff --git a/source/ps/CConsole.cpp b/source/ps/CConsole.cpp index cbea4ea66b..175e43efd9 100644 --- a/source/ps/CConsole.cpp +++ b/source/ps/CConsole.cpp @@ -52,8 +52,6 @@ namespace // For text being typed into the console. constexpr int CONSOLE_BUFFER_SIZE = 1024; -const char* CONSOLE_FONT = "mono-10"; - } // anonymous namespace CConsole* g_Console = 0; @@ -87,6 +85,7 @@ void CConsole::Init() { // Initialise console history file m_MaxHistoryLines = g_ConfigDB.Get("console.history.size", 200); + m_consoleFont = g_ConfigDB.Get("console.font", std::string{"mono-10"}); m_HistoryFile = L"config/console.txt"; LoadHistory(); @@ -94,7 +93,7 @@ void CConsole::Init() UpdateScreenSize(g_xres, g_yres); // Calculate and store the line spacing - const CFontMetrics font{CStrIntern(CONSOLE_FONT)}; + const CFontMetrics font{CStrIntern(m_consoleFont)}; m_FontHeight = font.GetLineSpacing(); m_FontWidth = font.GetCharacterWidth(L'C'); m_CharsPerPage = static_cast(g_xres / m_FontWidth); @@ -200,7 +199,7 @@ void CConsole::Render(CCanvas2D& canvas) DrawWindow(canvas); CTextRenderer textRenderer; - textRenderer.SetCurrentFont(CStrIntern(CONSOLE_FONT)); + textRenderer.SetCurrentFont(CStrIntern(m_consoleFont)); // Animation: slide in from top of screen. const float deltaY = (1.0f - m_VisibleFrac) * m_Height; textRenderer.Translate(m_X, m_Y - deltaY); diff --git a/source/ps/CConsole.h b/source/ps/CConsole.h index 37e3e63d1b..40b7ec7a60 100644 --- a/source/ps/CConsole.h +++ b/source/ps/CConsole.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -103,6 +103,7 @@ private: VfsPath m_HistoryFile; int m_MaxHistoryLines; + std::string m_consoleFont; bool m_Visible; // console is to be drawn bool m_Toggle; // show/hide animation is currently active