[PR #18] [MERGED] Persist font settings via Windows Registry #22

Closed
opened 2026-03-03 12:01:46 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ForLoopCodes/legacy-notepad/pull/18
Author: @Copilot
Created: 2/4/2026
Status: Merged
Merged: 2/4/2026
Merged by: @ForLoopCodes

Base: mainHead: copilot/change-default-font-settings


📝 Commits (5)

  • 14e51d2 Initial plan
  • 007e9f2 Add font settings persistence via Windows Registry
  • 6d449d7 Improve code quality: use named constants for font size limits
  • 1492c70 Complete implementation of font settings persistence
  • 028710b Clean up: remove build artifacts and update .gitignore

📊 Changes

6 files changed (+96 additions, -1 deletions)

View changed files

📝 .gitignore (+3 -1)
📝 CMakeLists.txt (+1 -0)
📝 src/main.cpp (+2 -0)
📝 src/modules/dialog.cpp (+2 -0)
src/modules/settings.cpp (+69 -0)
src/modules/settings.h (+19 -0)

📄 Description

Font preferences (name and size) were not persisted across application restarts. Users had to reconfigure from Consolas 16pt every time.

Changes

New module: src/modules/settings.cpp

  • LoadFontSettings() - reads from HKCU\Software\LegacyNotepad on startup
  • SaveFontSettings() - writes when user changes font via Format menu
  • Font size validated to 8-72pt range

Integration points:

  • main.cpp - loads settings before window creation
  • dialog.cpp - saves settings after FormatFont() completes
  • CMakeLists.txt - added to build

Implementation

Registry values:

  • FontName (REG_SZ) - font face name
  • FontSize (REG_DWORD) - point size

Gracefully falls back to hardcoded defaults if registry key doesn't exist. Uses same registry pattern as existing theme.cpp.

void LoadFontSettings()
{
    HKEY hKey;
    if (RegOpenKeyExW(HKEY_CURRENT_USER, SETTINGS_KEY, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
    {
        // Read FontName and FontSize, validate, close key
        // Falls back to g_state defaults if values invalid
    }
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Not possible to change default font, font size etc</issue_title>
<issue_description>Hi and thanks for this app!

Legacy Notepad always reverts to Consolas, Regular, 16.

16 is way too big.

Not sure what the best approach is, either put a .ini or .cfg file in the same folder as the .exe, or maybe just store it in the registry.

Or maybe I'm missing something.

Have a nice day/evening</issue_description>

Comments on the Issue (you are @copilot in this section)

@ForLoopCodes on it

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ForLoopCodes/legacy-notepad/pull/18 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 2/4/2026 **Status:** ✅ Merged **Merged:** 2/4/2026 **Merged by:** [@ForLoopCodes](https://github.com/ForLoopCodes) **Base:** `main` ← **Head:** `copilot/change-default-font-settings` --- ### 📝 Commits (5) - [`14e51d2`](https://github.com/ForLoopCodes/legacy-notepad/commit/14e51d23b1ea1db770cb8303a33e1c49e8b935c4) Initial plan - [`007e9f2`](https://github.com/ForLoopCodes/legacy-notepad/commit/007e9f2920a6112bea3451898c8a294f0dd98a8d) Add font settings persistence via Windows Registry - [`6d449d7`](https://github.com/ForLoopCodes/legacy-notepad/commit/6d449d7e6a42d01b66ed9261f66c4df24782bfcf) Improve code quality: use named constants for font size limits - [`1492c70`](https://github.com/ForLoopCodes/legacy-notepad/commit/1492c7072874314f676eed8d7844d79e74762463) Complete implementation of font settings persistence - [`028710b`](https://github.com/ForLoopCodes/legacy-notepad/commit/028710b8ae3046ddf4a50ee04772b22edda6439c) Clean up: remove build artifacts and update .gitignore ### 📊 Changes **6 files changed** (+96 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+3 -1) 📝 `CMakeLists.txt` (+1 -0) 📝 `src/main.cpp` (+2 -0) 📝 `src/modules/dialog.cpp` (+2 -0) ➕ `src/modules/settings.cpp` (+69 -0) ➕ `src/modules/settings.h` (+19 -0) </details> ### 📄 Description Font preferences (name and size) were not persisted across application restarts. Users had to reconfigure from Consolas 16pt every time. ## Changes **New module: `src/modules/settings.cpp`** - `LoadFontSettings()` - reads from `HKCU\Software\LegacyNotepad` on startup - `SaveFontSettings()` - writes when user changes font via Format menu - Font size validated to 8-72pt range **Integration points:** - `main.cpp` - loads settings before window creation - `dialog.cpp` - saves settings after `FormatFont()` completes - `CMakeLists.txt` - added to build ## Implementation Registry values: - `FontName` (REG_SZ) - font face name - `FontSize` (REG_DWORD) - point size Gracefully falls back to hardcoded defaults if registry key doesn't exist. Uses same registry pattern as existing `theme.cpp`. ```cpp void LoadFontSettings() { HKEY hKey; if (RegOpenKeyExW(HKEY_CURRENT_USER, SETTINGS_KEY, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { // Read FontName and FontSize, validate, close key // Falls back to g_state defaults if values invalid } } ``` <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Not possible to change default font, font size etc</issue_title> > <issue_description>Hi and thanks for this app! > > Legacy Notepad always reverts to Consolas, Regular, 16. > > 16 is way too big. > > Not sure what the best approach is, either put a .ini or .cfg file in the same folder as the .exe, or maybe just store it in the registry. > > Or maybe I'm missing something. > > Have a nice day/evening</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > <comment_new><author>@ForLoopCodes</author><body> > on it </body></comment_new> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes ForLoopCodes/legacy-notepad#13 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 12:01:46 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/legacy-notepad#22
No description provided.