Skip to content

Make widget default font size consistent with plain Text - #12237

Merged
ogoffart merged 5 commits into
masterfrom
olivier/fix-#12226
Jun 30, 2026
Merged

Make widget default font size consistent with plain Text#12237
ogoffart merged 5 commits into
masterfrom
olivier/fix-#12226

Conversation

@ogoffart

@ogoffart ogoffart commented Jun 25, 2026

Copy link
Copy Markdown
Member

Widgets rendered their default text at a different size than a plain Text {}, so e.g. a Switch label didn't match adjacent text.

  • Fluent & Cosmic: body text used 14/13 rem; anchor it to 1rem so it matches a plain Text.
  • Express all theme font sizes as their design-spec point sizes over the base that maps to 1rem (e.g. 28pt * 1rem / 14pt) instead of magic factors.
  • Material: anchor 1rem to the 14sp default text size (Body Medium / the
    platform default font) instead of Body Large (16sp), so normal labels match a plain Text while LineEdit (Body Large) stays larger, per the M3 spec.
  • Drop now-redundant font-size/font-weight: …body… bindings on plain Text elements (they just re-set the default).

Fixes #12226

@ogoffart
ogoffart force-pushed the olivier/fix-#12226 branch from 028876b to 9a48288 Compare June 25, 2026 10:44
ogoffart added 3 commits June 25, 2026 13:45
The Fluent and Cosmic styles used 14/13 rem for the widget body text,
which is slightly larger than a plain Text element (1 rem). Anchor the
body size to 1 rem so widgets and Text match. Express the font sizes as
the design spec point sizes relative to the base that maps to 1 rem.

Fixes: #12226
The scale was anchored so body-large (16sp) maps to 1rem, which made a
plain Text larger than a normal widget label. Anchor it to 14sp instead
(the Material default text size, and what the platform reports as the
default font), so a plain Text matches a normal label. body-large, used
for text input, is then 1.14rem, larger than a label, as the spec
intends. Put the RadioButton labels on the 14sp title-small role so the
selection controls are consistent.
In the Fluent, Cupertino and Cosmic styles the body text style is 1rem
with the normal weight, which is already the default for a Text. Setting
font-size and font-weight to the body style on a plain Text only adds
bindings without changing the result, so remove them.
@ogoffart
ogoffart force-pushed the olivier/fix-#12226 branch from 9a48288 to 5ee8120 Compare June 25, 2026 11:45
Comment thread examples/bevy/Cargo.lock

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks unrelated :)

out property <TextStyle> body: { font-size: 14 * 0.0769rem, font-weight: FontWeight.normal };
out property <TextStyle> body-strong: { font-size: 14 * 0.0769rem, font-weight: FontWeight.semi-bold };
out property <TextStyle> title: { font-size: 24 * 0.0769rem, font-weight: FontWeight.light };
out property <TextStyle> body: { font-size: 14pt * 1rem / 14pt, font-weight: FontWeight.normal };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this should match our default font size, is it still used anywhere?

@tronical tronical left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, with the lock file change gone this LGTM :)

… styles

The textedit page navigation test asserts where PageDown lands, which
depends on the input font size. Material renders the input larger than
the other styles, so the cursor lands one column over and the assertion
failed. Pin the font size to 1rem so every style behaves the same.
Comment thread tests/cases/widgets/textedit.slint
@ogoffart ogoffart added the candidate-for-bugfix-release Label for PRs that would make sense to cherry-pick into a spontaneously created bug fix release bran label Jun 30, 2026
The body text style resolves to 1rem and normal weight, which is what an
unset font-size/font-weight already gives. Remove it from the Fluent,
Cupertino and Cosmic settings and let the default apply.
@ogoffart
ogoffart merged commit cad72ee into master Jun 30, 2026
49 checks passed
@ogoffart
ogoffart deleted the olivier/fix-#12226 branch June 30, 2026 11:23
tronical pushed a commit that referenced this pull request Jul 1, 2026
* Make the default font size consistent between widgets and Text

The Fluent and Cosmic styles used 14/13 rem for the widget body text,
which is slightly larger than a plain Text element (1 rem). Anchor the
body size to 1 rem so widgets and Text match. Express the font sizes as
the design spec point sizes relative to the base that maps to 1 rem.

Fixes: #12226

* Material: use the 14sp default text size as the 1rem base

The scale was anchored so body-large (16sp) maps to 1rem, which made a
plain Text larger than a normal widget label. Anchor it to 14sp instead
(the Material default text size, and what the platform reports as the
default font), so a plain Text matches a normal label. body-large, used
for text input, is then 1.14rem, larger than a label, as the spec
intends. Put the RadioButton labels on the 14sp title-small role so the
selection controls are consistent.

* widgets: drop redundant body font bindings on plain Text

In the Fluent, Cupertino and Cosmic styles the body text style is 1rem
with the normal weight, which is already the default for a Text. Setting
font-size and font-weight to the body style on a plain Text only adds
bindings without changing the result, so remove them.

* tests: pin the TextEdit font size so page navigation is stable across styles

The textedit page navigation test asserts where PageDown lands, which
depends on the input font size. Material renders the input larger than
the other styles, so the cursor lands one column over and the assertion
failed. Pin the font size to 1rem so every style behaves the same.

* widgets: drop the body font role now that it equals the default

The body text style resolves to 1rem and normal weight, which is what an
unset font-size/font-weight already gives. Remove it from the Fluent,
Cupertino and Cosmic settings and let the default apply.

(cherry picked from commit cad72ee)
@tronical tronical removed the candidate-for-bugfix-release Label for PRs that would make sense to cherry-pick into a spontaneously created bug fix release bran label Jul 1, 2026
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.

Default font size is inconsistent between different widgets using Fluent theme

3 participants