Fix pixel-perfect GL rendering at non-integer device pixel ratios#1709
Closed
Fix pixel-perfect GL rendering at non-integer device pixel ratios#1709
Conversation
Agent-Logs-Url: https://github.com/solvespace/solvespace/sessions/38f92405-4968-46b4-8a3d-bb8f68a94a56 Co-authored-by: phkahler <[email protected]>
Copilot
AI
changed the title
[WIP] Fix uneven stroke width in font rendering
Fix pixel-perfect GL rendering at non-integer device pixel ratios
Apr 1, 2026
Member
|
@phkahler I'll take a look... |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


At display scaling other than 100% (DPR ≠ 1), the OpenGL canvas renders text with visibly uneven stroke widths because glyph positions snap to CSS pixel boundaries rather than physical pixel boundaries, and pixel-grid alignment is disabled entirely for all non-1× DPR values.
Root causes
AlignToPixelGridsnapped to CSS pixel grid, not physical pixel grid.floor(v.x) + 0.5centers on integer CSS pixels. At DPR=1.5, those land at 0.0, 1.5, 3.0… physical pixels — every other position off-center, producing alternating 1- and 2-pixel-wide strokes.gridFitunconditionally disabled for DPR ≠ 1, so no pixel alignment was applied at any scaled DPI. The guard existed because the old snap formula was wrong for non-1× DPR.(Web only) Canvas CSS display size not explicitly set after
emscripten_set_canvas_element_size. Thewidth: 100%rule could resolve to a fractional CSS size that doesn't divide evenly by DPR, causing the browser to apply bilinear interpolation over the bitmap.Changes
src/render/render.cpp— FixAlignToPixelGridto snap to physical pixel centers for any DPR:src/draw.cpp,src/textwin.cpp— SetgridFit = trueunconditionally (wasGetDevicePixelRatio() == 1). The fixed snap formula handles all DPR values correctly.src/platform/guihtml.cpp— After resizing the canvas bitmap, override the inline CSS size topixelWidth / DPR×pixelHeight / DPRpx, ensuring the browser maps the bitmap 1:1 to physical pixels without any interpolation pass.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
gitlab.com/usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED rchives/libsm-de--gdwarf-5 rchi�� /local/bin/cmake-o rchives/xtrans-dCMakeFiles/mimalloc-static.dir/src/stats.c.o fig h/TryCompile-6O2/usr/local/bin/cmake systemd-journald-E systemd-networkdcmake_echo_color fig dedi�� ibdxfrw/intern graphics-window ibdxfrw e/extlib/libdxfrw -isystem /home/REDACTED/work/solvespace/solvespace/extlib/mimalloc/include -isy --global /opt/pipx_bin/gi/home/REDACTED/work/solvespace/solvespace/extlib/libdxfrw/intern e/git(dns block)/usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED -dumpbase --de�� 36 p.ci vespace vespace/res kmsg dwgreader18.cpp./home/REDACTED/work/solvespace/solvespace/extlib/libdxfrw/intern iles/resources.d-I --fo�� ibdxfrw/intern --force-confdef ibdxfrw es --progress-nuas uild/CMakeFiles very window/other-sup-I(dns block)If you need me to access, download, or install something from one of these locations, you can either: