Conversation
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.
| "sync" | ||
| ) | ||
|
|
||
| const ( |
There was a problem hiding this comment.
In the tool package we already have a file called constants.go where we can define all the constants, can we put them there?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
| } | ||
|
|
||
| func (cm *ConfigurationManager) Save(cfg Configuration) error { | ||
| cfg.General.BaseFontSizePx = clampBaseFontSizePx(cfg.General.BaseFontSizePx) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
You mean like adding a specific function for font-related params? I can do that
There was a problem hiding this comment.
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
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
refreshboolean 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 🧪