Skip to content

Commit

Permalink
Merge pull request Modernizr#602 from rodneyrehm/master
Browse files Browse the repository at this point in the history
SubPixel Font Rendering feature detect, closes Modernizr#602
  • Loading branch information
ryanseddon committed Jun 3, 2012
2 parents da41692 + 63f74c6 commit d1d367b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions feature-detects/css-subpixelfont.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Test for SubPixel Font Rendering
* (to infer if GDI or DirectWrite is used on Windows)
* Authors: @derSchepp, @gerritvanaaken, @rodneyrehm, @yatil, @ryanseddon
* Web: https://github.com/gerritvanaaken/subpixeldetect
*/
Modernizr.addTest('subpixelfont', function() {
var bool,
styles = "#modernizr{position: absolute; top: -10em; visibility:hidden; font: normal 10px arial;}#subpixel{float: left; font-size: 33.3333%;}";

// see https://github.com/Modernizr/Modernizr/blob/master/modernizr.js#L97
Modernizr.testStyles(styles, function(elem) {
var subpixel = elem.firstChild;

subpixel.innerHTML = 'This is a text written in Arial';

bool = window.getComputedStyle
? window.getComputedStyle(subpixel, null).getPropertyValue("width") !== '44px'
: false;
}, 1, ['subpixel']);

return bool;
});

0 comments on commit d1d367b

Please sign in to comment.