Crisp scaled taskbar text - #1402
Conversation
|
Download the artifacts for this pull request: |
3450f7b to
b1e72a6
Compare
b1e72a6 to
1765626
Compare
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.
1765626 to
0ee96ed
Compare
|
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?) |
|
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. |
Oh you're right, it's also misaligned in master with any scale above 100%, so maybe this whole point is moot!
In light of the above, I'm good with leaving it as-is without an option. We can always add one later if needed :) |
|
Okay, nice. Sounds good to me. |
|
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? |
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
round(fontSize × scale)with a1/scalecounter-transform, so the glyphs land on the pixel grid (net identity transform)
while the label still fills its scaled slot.
TextScalerhelper that walks thecontrol's text and scales each
TextBlock. Applied only inside the taskbar, notthe Properties-window preview.
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
the host window type).
GlobalFontSize, so the 12px themes(Vista/Longhorn Aero) scale correctly. The Vista Aero positioning override was
moved onto the new indicator box.
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.