Permalink
Browse files

Merge pull request #602 from rodneyrehm/master

SubPixel Font Rendering feature detect, closes #602
  • Loading branch information...
2 parents 92b19ae + 08bd778 commit 0338d1da400dcbfdac78e38e654b8b5991c3a91b @ryanseddon ryanseddon committed Jun 3, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 feature-detects/css-subpixelfont.js
@@ -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 0338d1d

Please sign in to comment.