Skip to content

fix(Win32): scale window sizes and Material Symbol boxes by the window's DPI - #8

Open
vitalyster wants to merge 3 commits into
codelynx:developfrom
vitalyster:dpi_fixes
Open

fix(Win32): scale window sizes and Material Symbol boxes by the window's DPI#8
vitalyster wants to merge 3 commits into
codelynx:developfrom
vitalyster:dpi_fixes

Conversation

@vitalyster

@vitalystervitalyster commented Aug 20, 2026

Copy link
Copy Markdown

Win32 DPI fixes (three commits):

  1. Material Symbol glyph boxes scale with DPI. The glyph font is scaled by the monitor DPI but the STATIC box holding it was not, so icons were cropped on high-DPI displays.

  2. Window sizes are scaled by the window's own DPI. SwiftUI window sizes (defaultWindowSize, windowSizing(.size), min/max track sizes) are logical points; the backend created windows at the same number of physical pixels, so a 1100×720 window appeared as 550×360 at 200% DPI. Specified sizes are now scaled by GetDpiForWindow (per-monitor). Windows without a specified size keep the CW_USEDEFAULT system default instead of the previous hardcoded 400×300/500×600 fallbacks.

  3. Text measurement and D2D rendering scale with DPI. Text rendered at DPI-scaled font sizes while the boxes around it were measured at 96 DPI, so at 200% DPI buttons came out half-size and cropped. measureText now scales by the window's DPI; the D2D flat button paints with the scaled default size; the D2D render target pins its DPI to 96 so drawing coordinates match the layout engine's physical pixels.

Expected doc impact: parity matrix / implementation tracker may want a DPI-awareness note (coordinator-owned).

The glyph font is scaled by the monitor DPI (pointSize × dpiScale) but
the STATIC box holding it was not, so icons were cropped on high-DPI
displays. Scale the box too.
Co-Authored-By: Claude <noreply@anthropic.com>
SwiftUI window sizes are logical points; windows were created at the
same number of physical pixels, so a 1100×720 window appeared as
550×360 at 200% DPI. Sizes the app specifies (defaultWindowSize,
windowSizing(.size), min/max track sizes) are now scaled by the
window's own DPI (per-monitor).
Windows without a specified size keep the CW_USEDEFAULT system default
instead of the previous hardcoded 400×300/500×600 fallbacks.
Text rendered at DPI-scaled font sizes while the boxes around it were
measured at 96 DPI, so at 200% DPI buttons came out half-size and
cropped.
- measureText scales the default 14pt by the window's DPI (DirectWrite
format and GDI fallback)
- the D2D flat button paints with the scaled default size
- the D2D render target pins its DPI to 96 so drawing coordinates match
the layout engine's physical pixels (the default system-DPI target
reinterpreted every coordinate as DIPs and doubled sizes at 200%)
Sign up for freeto 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.

1 participant

@vitalyster