Of DPI and Microsoft's Lazyness

Windows uses a DPI of 96 when rendering objects on your screen. It’s been set at this value since the dawn of time. Why 96? Only the great gods of computers know.

But now we’ve got higher resolution screens. Screens that are 15 inches in physical size but support up to 1280×1024 in resolution. At that resolution things look very tiny and are almost unreadable on a 15 inch screen.

The solution is to increase the DPI. In doing so Windows will increase the size of the fonts and other window objects (buttons, bars, etc) making letters at 1280×1024 @ 120 dpi look the same as letters at 1024×768 @ 96 dpi. The added benefit is that fonts will have an increased resolution, meaning more space to draw it, meaning they’ll look stronger, crisper, and in general a whole lot better.

However, images still don’t scale. A 190 pixel wide image is still 190 pixels wide. At 1024×768 it will eat up 10% of the screen’s width, while at 1280×1024 it’ll eat up only 7%. This means user interfaces that use images, icons, video, etc. may wind up looking odd or (worst case) breaking entirely under a DPI different from the one it was designed at.

This includes web pages.

Thus Microsoft created something I’ve seen unofficially called active scaling. It’s a little known feature that’s been around since IE 6.0 which, when enabled, will resize images to fix the same physical space on screen as they would have at a lower DPI. The math is [image resolution] * ( 120 / 90 ). So in the case of a 190 pixel wide image you’d get 190 * 1.25 = 237.5 pixels wide.

Uh oh.

A decimal point.

IE does not do well with decimal points.

And this time IS NO DIFFERENT!

Two users contacted me about the Bridgewater State College web site not loading properly. The body of the page was being pushed down below the left-hand column. They sent me screenshots and it was immediately apparent they had done something to increase their system font sizes.

However I notice the edges of the images were blurry or jagged. It became obvious there was something more that just increased font sizes at work here.

Through some luck I was able to track the source of the problem to a rounding bug in IE related to active scaling.

Since I’ve had more than my fair share of rounding bugs in IE I knew immediately what the fix for it was. Simply add a -1px margin to the opposing side of any floated element. Meaning if you’ve got an element floating right, you set -1px to the left-margin of that box. Or if it’s left floated, -1px margin to the right side of the box.

Here’s a simple CSS hack that targets IE for this purpose:

* html #content-column,
*:first-child+html #content-column {
  margin-left: -1px;
}

Obviously replace #content-column with your element’s selector and change margin-left to margin-right as needed.

These rounding bugs have been with IE since it’s creation. They are something Microsoft has known about for years, and yet they are either unable or unwilling to fix them. I believe they are part of a larger issue, related to all the hasLayout bullshit. I think the rendering engine for IE needs a complete rewrite. But Microsoft won’t do that. They haven’t yet, why start now? I think the reason for this is because they don’t care. Why waste resources resolving a bug that only a handful of web developers are annoyed by? Web developers have been working around IE for years, they can keep working around IE.

I wish we, as web developers, could simply say “Fuck IE!”; to leave these bugs rather than hack around them. Tell our users to simply use a different browser because IE is so poor.

But we can’t.

If we do this we’re out of a job. IE still has the majority share of the browser user base. And why? Because it comes free with the most installed desktop OS on the planet. If we don’t work around it our web site become ugly or even inaccessible to the majority of the internet population. This is simply bad business.

And I fear any attempt to educate users about the problematic Internet Explorer will fall on deaf ears. The only thing that will rid us of IE is the same thing that rid us of Netscape 4: time. A lot of time.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s