Skip to content

Crisp scaled taskbar text - #1402

Open
rmnmjw wants to merge 3 commits into
dremin:masterfrom
rmnmjw:crisp-scaled-taskbar-text
Open

Crisp scaled taskbar text#1402
rmnmjw wants to merge 3 commits into
dremin:masterfrom
rmnmjw:crisp-scaled-taskbar-text

Conversation

@rmnmjw

@rmnmjw rmnmjw commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This PR contains a commit of #1401, so it should be gone as soon as the other PR is merged hopefully.

Summary

RetroBar scales the taskbar with a single ScaleTransform. At fractional scales
(125%, 150%, 175%, …) that stretches text which was laid out at its base size,
pushing glyphs off the pixel grid so they look blurry. This PR renders the
taskbar's text at a real, pixel-aligned size instead, keeping it crisp at any
scale while leaving the 100%/200% (whole-number) appearance unchanged.

What changed

  • Task button labels - rendered at round(fontSize × scale) with a 1/scale
    counter-transform, so the glyphs land on the pixel grid (net identity transform)
    while the label still fills its scaled slot.
  • Clock - same treatment via a small shared TextScaler helper that walks the
    control's text and scales each TextBlock. Applied only inside the taskbar, not
    the Properties-window preview.
  • Input language indicator - restructured so the text is centered by layout
    inside a box that is itself rendered at real pixel sizes with aliased edges, so
    the indicator stays crisp and consistently centered at every scale instead of
    drifting with per-scale rounding.

Behavior preserved

  • 100% and integer scales render exactly as before.
  • The Properties-window previews are unaffected (they aren't scaled - detected via
    the host window type).
  • Theme-aware: base font size is read from GlobalFontSize, so the 12px themes
    (Vista/Longhorn Aero) scale correctly. The Vista Aero positioning override was
    moved onto the new indicator box.
  • Vertical (left/right edge) taskbars are unchanged.

Testing

Built for net6.0-windows. Manually verified at 100 / 125 / 150 / 175 / 200%:
task labels, clock, and the language indicator are crisp and centered; the
Properties previews and vertical taskbars look normal.

Related issue

Partially addresses #1213: it covers the text half, crisp, pixel-aligned text (aliased when font smoothing is off) at every scale, not just 200%. Icons are still transform-scaled and remain a follow-up.

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

Comment thread RetroBar/Controls/TaskButton.xaml Outdated
@rmnmjw
rmnmjw force-pushed the crisp-scaled-taskbar-text branch from 3450f7b to b1e72a6 Compare June 24, 2026 13:33
@rmnmjw
rmnmjw marked this pull request as draft June 24, 2026 13:44
@rmnmjw
rmnmjw force-pushed the crisp-scaled-taskbar-text branch from b1e72a6 to 1765626 Compare June 24, 2026 15:40
rmnmjw added 3 commits June 24, 2026 17:41
At a fractional taskbar scale (e.g. 150%), the taskbar's ScaleTransform
stretches text rendered at its base size, pushing glyph positions off
the pixel grid and making the text look blurry.

Add TextScaler, a shared helper that walks a control's visual tree and
renders each TextBlock at round(baseFontSize * scale) with a 1/scale
counter-transform, so glyphs land on the pixel grid (crisp) while still
occupying the scaled layout slot.

Apply it to the clock. Scaling is skipped outside the taskbar (e.g. the
properties window preview), detected via the host window type, and
re-applied when the taskbar scale or theme changes.
At a fractional taskbar scale (e.g. 150%), the taskbar's ScaleTransform
stretches text rendered at its base size, pushing glyph positions off
the pixel grid and making the text look blurry.

Render the task button label at a real, pixel-aligned font size instead,
routing it through the shared TextScaler helper: each label TextBlock
gets a font size of round(baseFontSize * scale) and a 1/scale
counter-transform, so its glyphs render with a net identity transform
(crisp) while still occupying the scaled layout slot. The scaling is
re-applied when the taskbar scale or theme changes.
Center the indicator text by layout and render the whole box at real,
pixel-aligned sizes so it stays crisp and consistently centered at any
taskbar scale, not just whole-number ones.

- Split the InputLanguage style into an InputLanguageBox (Border) that
  carries the background/size and a text style centered via
  HorizontalAlignment/VerticalAlignment, so vertical centering no longer
  depends on per-scale rounding of a fixed height and padding.
- Scale the box with a 1/scale counter-transform and round(size * scale)
  dimensions (and round(fontSize * scale) text), so both box and text
  render at whole-pixel sizes with a net identity transform.
- Give the box Aliased edges so a solid rectangle placed on a fractional
  device pixel keeps hard edges instead of anti-aliasing to a blur.
- Move the Vista Aero positioning override onto the box.

Scaling is skipped outside the taskbar (e.g. the properties window
preview), detected via the host window type, and re-applied when the
taskbar scale or theme changes.
@rmnmjw
rmnmjw force-pushed the crisp-scaled-taskbar-text branch from 1765626 to 0ee96ed Compare June 24, 2026 15:42
@dremin

dremin commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Nice! One unfortunate side effect of this is the clock in the Longhorn M5-M6 theme gets a bit misaligned. Not really sure if there is a great way around that? This may need to be an option that either users or themes could control (or maybe limit to only when smoothing is disabled?)

@rmnmjw

rmnmjw commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

The clock looks pretty good to me? Looks almost the same to the master branch except it's crips now? Maybe I'm misunderstanding the issue.

Since this is a project where most users probably have a very subjective preference, it might be best if the user decides? Maybe even per section?

How do you feel about giving the user the option to select from different rendering options? scaled / anti-aliased / crisp? Per section: Task Button, Language Indicator, Clock. Maybe move the rendering options into a new tab "Rendering"? I had a couple more ideas that might benefit from the space.

@dremin

dremin commented Jun 27, 2026

Copy link
Copy Markdown
Owner

The clock looks pretty good to me? Looks almost the same to the master branch except it's crips now? Maybe I'm misunderstanding the issue.

Oh you're right, it's also misaligned in master with any scale above 100%, so maybe this whole point is moot!

Since this is a project where most users probably have a very subjective preference, it might be best if the user decides? Maybe even per section?

How do you feel about giving the user the option to select from different rendering options? scaled / anti-aliased / crisp? Per section: Task Button, Language Indicator, Clock. Maybe move the rendering options into a new tab "Rendering"? I had a couple more ideas that might benefit from the space.

In light of the above, I'm good with leaving it as-is without an option. We can always add one later if needed :)

@rmnmjw
rmnmjw marked this pull request as ready for review June 27, 2026 06:56
@rmnmjw

rmnmjw commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Okay, nice. Sounds good to me.

@dremin

dremin commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Been doing some more testing and noticed the centering of the input language text is too low on several themes, including custom ones, could you look into making the related changes more compatible so themes don't require fixes?

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