Re: [CSS21] [css3-values] px and device pixels

I think the spec doesn't need to say how this works, other than recommend
that 1px is close to 1/96 of an inch at regular screen distances. And I
don't think the spec should say how zooming works.

But FYI here's what we do In Gecko 1.9...  a CSS px is normally an integer
number of device pixels --- max(1, floor(dpi/96)), where dpi is the DPI of
the device. For printers it doesn't really matter what you choose for the
dpi since we support subpixel layout and don't round px measurements except
for borders, which are rounded to device pixels.

For zooming, we scale the device-pixels-per-CSS-pixel ratio, and allow it to
take non-integer values. The output still looks great on almost all sites,
probably because our subpixel layout means this doesn't usually change the
layout at all, except for border rounding as I mentioned above. (We fixed
some problems with borders by always rounding border widths down (except we
avoid rounding down to zero) ... that avoids gross layout changes due to
elements with borders not fitting in a container.) If you're careful about
snapping graphics coordinates to pixel boundaries when you draw, and deal
with a handful of other interesting low-level graphics issues, there don't
seem to be many visual problems in the wild.

So, while initially I thought requiring a CSS pixel to be an integer number
of device pixels would be necessary for rendering to not suck, experience so
far suggests that it's not necessary, providing you do the other things

"He was pierced for our transgressions, he was crushed for our iniquities;
the punishment that brought us peace was upon him, and by his wounds we are
healed. We all, like sheep, have gone astray, each of us has turned to his
own way; and the LORD has laid on him the iniquity of us all." [Isaiah

Received on Friday, 28 March 2008 11:17:13 UTC