{"id":164823,"date":"2014-03-05T14:14:26","date_gmt":"2014-03-05T21:14:26","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=164823"},"modified":"2014-03-06T07:11:38","modified_gmt":"2014-03-06T14:11:38","slug":"text-rendering","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/t\/text-rendering\/","title":{"rendered":"text-rendering"},"content":{"rendered":"
The The You can see some before\/after examples here<\/a>. Sometimes the result is just straight up better kerning:<\/p>\n The Be aware that Windows, Linux and OS X each (may) have different text-rendering engines. Not to mention that different browsers each have their own text rendering defaults, so there is no guarantee that your font treatments will be displayed as intended on the user\u2019s system. You can learn more about type rendering systems and operating systems on the Typekit blog<\/a>.<\/p>\n There are four possible values:<\/p>\n The Ligatures are combinations of letters that tend to look better and are more readable as a combined glyph. An example of this is the letters \u2018f\u2019 and \u2018i\u2019. They can form the ligature \u2018fi\u2019 as in the word \u2018find\u2019. You can learn more about them here<\/a>.<\/p>\n Some font files contain additional information about how the font should be rendered. When it is said that there is a tradeoff between speed and precision, they aren’t kidding. There can be significant performance issues<\/a> to consider. That article is worth quoting entirely:<\/p>\n There are actually significant, effectively fatal performance problems (such as 30-second loading delays, or longer) on mobile devices when using optimizeLegibility for long pages. Apply it only if you know what the maximum text length will be. (Also, avoid using it for Android clients, at least on the older versions that everyone still uses: its font renderer often has very strange bugs when this mode is enabled.)<\/p>\n I did some testing with Instapaper to determine approximate optimizeLegibility performance limits. A 5,000-word article in Instapaper for iOS, for instance, will only use optimizeLegibility on devices with an A5-class or greater CPU. To avoid problems on older iOS devices, I wouldn\u2019t recommend using optimizeLegibility blindly and unconditionally on any pages longer than about 1,000 words. And I wouldn\u2019t recommend enabling it on Android at all.<\/p><\/blockquote>\n It’s tempting to do:<\/p>\n But be darn careful about that, seems dangerous especially when applied to an arbitrary page.<\/p>\ntext-rendering<\/code> property in CSS allows you to choose quality of text over speed (or vice versa) allowing you to fine tune optimization by suggesting to the browser as to how it should render text on the screen. Said another way in MDN<\/a>:<\/p>\n
text-rendering<\/code> CSS property provides information to the rendering engine about what to optimize for when rendering text. The browser makes trade-offs among speed, legibility, and geometric precision.<\/p><\/blockquote>\n
text-rendering<\/code> property is not defined in any CSS standard<\/strong>. It’s actually an SVG property<\/a>. However, Gecko\/WebKit\/Blink browsers let you apply this property to HTML elements.<\/p>\n
\n
geometricPrecision<\/code> can make text using those fonts look good. When SVG font is scaled, the browser calculates pixel size, then rounds to the nearest integer. The
geometricPrecision<\/code> property allows for more fluid scaling. Note: Only WebKit browsers apply this fluid value, Gecko treats the value just like
optimizeLegibility<\/code>.<\/li>\n<\/ul>\n
< 20px enables ligatures<\/h3>\n
optimizeLegibility<\/code> keyword enables ligatures in text smaller than 20px for some fonts. (like Calibri or D\u00e9j\u00e0Vu) This 20px threshold value can be changed in Gecko via the
browser.display.auto_quality_min_font_size<\/code> user preference.<\/p>\n
optimizeLegibility<\/code> makes use of this information, and
optimizeSpeed<\/code> does not. <\/p>\n
Example<\/h3>\n
p.legibility {\r\n text-rendering: optimizeLegibility;\r\n}\r\np.speed {\r\n text-rendering: optimizeSpeed;\r\n}<\/code><\/pre>\n
Performance<\/h3>\n
\/* Probably not advisable *\/\r\nbody {\r\n text-rendering: optimizeLegibility;\r\n}<\/code><\/pre>\n
Browser Support<\/h3>\n