css-subpixelfont.js 880 B

1234567891011121314151617181920212223
  1. /*
  2. * Test for SubPixel Font Rendering
  3. * (to infer if GDI or DirectWrite is used on Windows)
  4. * Authors: @derSchepp, @gerritvanaaken, @rodneyrehm, @yatil, @ryanseddon
  5. * Web: https://github.com/gerritvanaaken/subpixeldetect
  6. */
  7. Modernizr.addTest('subpixelfont', function() {
  8. var bool,
  9. styles = "#modernizr{position: absolute; top: -10em; visibility:hidden; font: normal 10px arial;}#subpixel{float: left; font-size: 33.3333%;}";
  10. // see https://github.com/Modernizr/Modernizr/blob/master/modernizr.js#L97
  11. Modernizr.testStyles(styles, function(elem) {
  12. var subpixel = elem.firstChild;
  13. subpixel.innerHTML = 'This is a text written in Arial';
  14. bool = window.getComputedStyle ?
  15. window.getComputedStyle(subpixel, null).getPropertyValue("width") !== '44px'
  16. : false;
  17. }, 1, ['subpixel']);
  18. return bool;
  19. });