Skip to content

Font customization#150

Draft
speziato wants to merge 3 commits intomainfrom
feat/add-font-settings
Draft

Font customization#150
speziato wants to merge 3 commits intomainfrom
feat/add-font-settings

Conversation

@speziato
Copy link
Copy Markdown
Collaborator

@speziato speziato commented May 9, 2026

Summary 💡

This PR adds system fonts retrieval to be used by the frontend, to enable users to change their preferred font for the general interface and for monospaced inputs.

Closes: #115

Description 📝

This implementation reads fonts from system folders (which are selected based on the build target), deduplicates all font families for the same font, and classifies them (monospace or not).

This also implements a caching mechanism to avoid reloading all fonts every time. The cache can be invalidated with the refresh boolean in go function's invocations.

It adds three new configuration parameters, which are backwards compatible: if missing, treat as default (font size 14px, font families as defined by the frontend by default).

A new go dependency (golang.org/x/image v0.39.0) to read font metadata was added.

Breaking Changes 💔

None.

Tests performed 🧪

  • All new tests specific for font deduplication, validation and classification pass
  • No regression with an old configuration
  • Font preferences are saved and used on closing and reopening the app

This also implements a caching mechanism to avoid reloading all fonts every time. The cache can be invalidated with the `refresh` boolean.

The implementation also uses different files based on the build target to list the correct folders based on the underlying os.

A new dependency to read font metadata was added.
@speziato speziato linked an issue May 9, 2026 that may be closed by this pull request
"sync"
)

const (
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the tool package we already have a file called constants.go where we can define all the constants, can we put them there?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought those would be better placed here because they are not app-wide constants, they are just configuration defaults. That said, if you prefer I can move those to the tool package

Copy link
Copy Markdown
Collaborator

@matstech matstech May 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your point, but that file already contains app-level constants, so we can add those there as well and then refactor the entire approach to create more than one point for defining constants. Does that make sense?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread internal/configuration/configuration_manager.go
}

func (cm *ConfigurationManager) Save(cfg Configuration) error {
cfg.General.BaseFontSizePx = clampBaseFontSizePx(cfg.General.BaseFontSizePx)
Copy link
Copy Markdown
Collaborator

@matstech matstech May 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it might be better to include some specific functions in app.go (and in the configuration manager) to configure the two parameters handled by this function in some way.

In other words, does this approach follow the style of the entire backend?

Copy link
Copy Markdown
Collaborator Author

@speziato speziato May 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean like adding a specific function for font-related params? I can do that

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm about to do this, but I noticed that some config params are not exposed like this already (specifically, the ones for update checks), we should also add those in another PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add configuration settings for font family and size

2 participants