View Full Version : sub-pixel Problem in IE9

7 Jul 2012, 9:38 AM
Some code in Element.style.js.

// IE9 Direct2D dimension rounding bug
if (Ext.supports.Direct2DBug) {
// get the fractional portion of the sub-pixel precision width of the element's text contents
floating = me.adjustDirect2DDimension(WIDTH);
if (preciseWidth) {
width += floating;
// IE9 also measures fonts with sub-pixel precision, but unlike Gecko, instead of rounding the offsetWidth down,
// it rounds to the nearest integer. This means that in order to ensure that the width includes the full
// width of the text contents we need to increment the width by 1 only if the fractional portion is less than 0.5
else if (floating > 0 && floating < 0.5) {

i write a div with width 16.25px.
it was displayed in ie9 as 16px(rounding down), not 17px(rounding up).
so, if the code [width++;] is used, it is bigger then the real div size.

can anyone tell me in which case the code [width++;] is needed?