3 ms·
The reason why Apple doesn't do fractional scaling is rounding errors: if you have a design that's aligned to the pixel grid at 1x, it's only guaranteed to rema
by kmeisthax 6y ago
The reason why Apple doesn't do fractional scaling is rounding errors: if you have a design that's aligned to the pixel grid at 1x, it's only guaranteed to remain aligned to that grid if you scale by other integers. If you aren't on the pixel grid, then the layout engine has to round sizes up or down to fit, which is dangerous. You're adding error to layout and then multiplying it by the number of elements being sized.
This gets particularly bad on the web, where a number of different tricks have been employed by browser vendors over the years to avoid rounding errors (see https://www.palantir.net/blog/responsive-design-s-dirty-little-secret https://www.palantir.net/blog/responsive-design-s-dirty-litt...). If you have, say, a float-column layout with percentage widths, then rounding errors can easily wind up making things either not line up or, worse, actually overflow their containers for no reason, breaking the layout. Throwing non-integer scaling into the mix makes this even worse.
Of course, this is a tractable problem, but it was much easier for Apple to just render-and-downscale from the nearest whole-number factor instead of making the lives of any developer with custom layout engines that much harder.
- chrisseaton 6y agoI don't get it - why does alignment matter when pixels are so small you've got no hope of seeing if something is aligned down to such a small measurement or not?
- saagarjha 6y agoApple agrees, since they’ve stopped pixel-aligning things now.
- kmeisthax 6y agoReally? Or are they just doing the same "render at a higher resolution and then downscale" trick that they did for the iPhone 6+, 7+, and 8+? (For context: https://medium.com/we-are-appcepted/the-curious-case-of-iphone-6-1080p-display-b33dac5bbcb6 https://medium.com/we-are-appcepted/the-curious-case-of-ipho... )
- kmeisthax 6y agoNormally it doesn't, but there's edge cases where errors can stack up and cause the entire layout to break. A related problem happens in word processors: if you just layout and render a document at 1x, but at print time, you layout and render at any higher resolution; you will get a different layout. Lines of text that are just over the width of the page when rounded to the 1x pixel grid will be just under the width of the page at the higher-density grid of a high-DPI printer. This happens even at integer scales because fonts are designed on abstract grids that have no relation to (and are far finer than) the pixel grid that the document will be displayed on printed on. (Complicating things, Windows intentionally renders fonts using custom rounding logic to force them onto the pixel grid as much as possible, this is known as ClearType. macOS doesn't do this nearly as heavily, which is why fonts look less sharp but more faithful on non-Retina Macs.) AFAIK word processors either have to always round metrics down (so that layout decisions are deterministic at all scales) or always work on a 1x layout and render at higher resolutions using the 1x layout metrics.