Skip to content

fix: honor fontFamily, remove unused primaryColor and fontSize#11

Open
johnkferguson wants to merge 1 commit into
xCaptaiN09:mainfrom
johnkferguson:fix/honor-config-keys
Open

fix: honor fontFamily, remove unused primaryColor and fontSize#11
johnkferguson wants to merge 1 commit into
xCaptaiN09:mainfrom
johnkferguson:fix/honor-config-keys

Conversation

@johnkferguson
Copy link
Copy Markdown

Noticed while customizing the theme that theme.conf declares primaryColor, fontFamily, and fontSize, and the flake accepts all three as overrides — but none of them are actually read by any QML. Setting them does nothing.

This PR:

  • Drops primaryColor and fontSize. They're not referenced anywhere in the QML, so they were silent no-ops.
  • Wires config.fontFamily into Main.qml via two derived properties that fall back to the bundled FontLoaders when unset.
  • Sets the default fontFamily to Google Sans Flex Freeze — the actual family name embedded in assets/fonts/FlexRounded-*.ttf (verified with fc-query). The previous default FlexRounded was a string Qt couldn't resolve, but it didn't matter since the value was never read.

Small breaking change for the flake API: passing primaryColor or fontSize to .override { ... } now raises a Nix eval error instead of being silently ignored. No rendered behavior changes either way.

- Drop primaryColor and fontSize from theme.conf, flake.nix, README.
  Both were declared but never read by any QML; setting them was a no-op.
- Wire config.fontFamily into Main.qml via two derived properties with
  fallback to the bundled FontLoaders.
- Set the default fontFamily to "Google Sans Flex Freeze" (the actual
  family name embedded in assets/fonts/FlexRounded-*.ttf).
@johnkferguson johnkferguson changed the title fix(theme): honor fontFamily, remove unused primaryColor and fontSize fix: honor fontFamily, remove unused primaryColor and fontSize May 10, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces dynamic font family selection by adding properties that fall back to default fonts if no configuration is provided. It also cleans up the configuration by removing unused properties like primaryColor and fontSize from theme.conf, flake.nix, and the documentation. The review feedback suggests consolidating the redundant activeFontRegular and activeFontBold properties into a single activeFontFamily property to simplify the logic and improve maintainability, as the underlying font family is the same for both weights.

Comment thread Main.qml
Comment on lines +236 to +237
property string activeFontRegular: (config.fontFamily && config.fontFamily.length > 0) ? config.fontFamily : fontRegular.name
property string activeFontBold: (config.fontFamily && config.fontFamily.length > 0) ? config.fontFamily : fontBold.name
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The properties activeFontRegular and activeFontBold are redundant because the bundled fonts share the same family name (Google Sans Flex Freeze). You can consolidate them into a single property, activeFontFamily, and simplify the logic using the logical OR operator. This improves maintainability and reduces code duplication.

    property string activeFontFamily: config.fontFamily || fontRegular.name

Comment thread Main.qml
color: container.extractedAccent
font.pixelSize: 22
font.family: fontRegular.name
font.family: activeFontRegular
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update to use the consolidated activeFontFamily property.

        font.family: activeFontFamily

Comment thread Main.qml
backgroundSource: config.background
baseAccent: container.extractedAccent
fontFamily: fontRegular.name
fontFamily: container.activeFontRegular
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update to use the consolidated activeFontFamily property. Also, the container. prefix is unnecessary here as the property is visible in the scope.

            fontFamily: activeFontFamily

Comment thread Main.qml
color: container.extractedAccent
font.pixelSize: 48
font.family: fontBold.name
font.family: activeFontBold
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update to use the consolidated activeFontFamily property. Qt will automatically select the bold weight of the family because font.weight: Font.Bold is set.

                            font.family: activeFontFamily

Comment thread Main.qml
font.pixelSize: 24
font.weight: Font.Bold
font.family: fontRegular.name
font.family: activeFontRegular
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update to use the consolidated activeFontFamily property.

                        font.family: activeFontFamily

Comment thread Main.qml
color: container.extractedAccent
font.pixelSize: 14
font.family: fontRegular.name
font.family: activeFontRegular
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update to use the consolidated activeFontFamily property.

                    font.family: activeFontFamily

Comment thread Main.qml
color: isCurrent ? baseColor : "white"
font.pixelSize: 12
font.family: fontBold.name
font.family: activeFontBold
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update to use the consolidated activeFontFamily property. Qt will automatically select the bold weight of the family because font.weight: Font.Bold is set.

                            font.family: activeFontFamily

Comment thread Main.qml
color: isCurrent ? "white" : (hovered ? "#DDDDDD" : "#AAAAAA")
font.pixelSize: 15
font.family: fontRegular.name
font.family: activeFontRegular
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update to use the consolidated activeFontFamily property.

                        font.family: activeFontFamily

Comment thread Main.qml
color: isCurrent ? "white" : "#AAAAAA"
font.pixelSize: 14
font.family: fontRegular.name
font.family: activeFontRegular
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Update to use the consolidated activeFontFamily property.

                        font.family: activeFontFamily

@andreshungbz
Copy link
Copy Markdown

I was wondering why my font family wasn't applying when using the flake, but this fixed the issue. There are some spots where the font isn't applied, though (e.g., the "Press any key to unlock" text at the bottom).

On a side note, different fonts sometimes cause the clock hours/minutes to overlap. I think the culprit is the Clock.qml component which has its Column spacing hardcoded to -130. Works fine with the default font, since I think it already has large spacing.

With JetBrains Mono
image

With Arial (easier to see overlap)
image

I played around with adding a fontSpacing option (perhaps not the best name...), which works so you can set a custom spacing while keeping the default -130 if not defined (andreshungbz@4cf3334). Waiting first to see if this PR is merged, though.

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.

2 participants