fix(gui): make SVG icon rasterization DPI-aware in loadPixmap (#189) #266
Reference in New Issue
Block a user
Delete Branch "fix/toolbar-icon-dpi-scaling"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
BitmapFactory::loadPixmap()rendered all SVGs at a hardcoded 64x64 pixels regardless of display DPI. On HiDPI screens, Qt downscaled these low-resolution pixmaps to the toolbar icon size, producing chunky/aliased icons.Root Cause
loadPixmap()calledpixmapFromSvg(content, QSize(64, 64))without accounting for the device pixel ratio. A DPI-aware path already existed in the namedpixmapFromSvg(const char*, QSizeF)overload, but the genericloadPixmap()path (used by all toolbar icons) never used it.Fix
Multiply the render size by
getMaximumDPR()and tag the resulting pixmap withsetDevicePixelRatio(), matching the existing pattern in the named overload. This is a 3-line change insrc/Gui/BitmapFactory.cpp.Testing
tests/src/Gui/BitmapFactory.cppwith 3 GTest cases:PixmapFromSvgContentRendersAtRequestedSize-- verifies the raw content pathMaximumDPRIsAtLeastOne-- sanity check on DPR utilityPixmapFromSvgFileHasCorrectDPR-- end-to-end test: writes SVG to temp dir, loads viapixmap(), verifies DPR and physical sizeVerification
Visual inspection on HiDPI display recommended -- toolbar icons should appear crisp rather than chunky/aliased at all preference sizes (16, 24, 32, 48).
Closes #189