subpixelfont.js 942 B

123456789101112131415161718192021222324252627
  1. /*!
  2. {
  3. "name": "CSS Subpixel Fonts",
  4. "property": "subpixelfont",
  5. "tags": ["css"],
  6. "builderAliases": ["css_subpixelfont"],
  7. "authors": ["@derSchepp", "@gerritvanaaken", "@rodneyrehm", "@yatil", "@ryanseddon"],
  8. "notes": [{
  9. "name": "Origin Test",
  10. "href": "https://github.com/gerritvanaaken/subpixeldetect"
  11. }]
  12. }
  13. !*/
  14. define(['Modernizr', 'testStyles'], function(Modernizr, testStyles) {
  15. /*
  16. * (to infer if GDI or DirectWrite is used on Windows)
  17. */
  18. testStyles(
  19. '#modernizr{position: absolute; top: -10em; visibility:hidden; font: normal 10px arial;}#subpixel{float: left; font-size: 33.3333%;}',
  20. function(elem) {
  21. var subpixel = elem.firstChild;
  22. subpixel.innerHTML = 'This is a text written in Arial';
  23. Modernizr.addTest('subpixelfont', window.getComputedStyle ?
  24. window.getComputedStyle(subpixel, null).getPropertyValue('width') !== '44px'
  25. : false);
  26. }, 1, ['subpixel']);
  27. });