mozilla

Revision 25019 of text-rendering

  • Revision slug: CSS/text-rendering
  • Revision title: text-rendering
  • Revision id: 25019
  • Created:
  • Creator: grendel
  • Is current revision? No
  • Comment Updated all the values to include both WebKit and Gecko browsers; 51 words added, 10 words removed

Revision Content

Summary

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. The text-rendering property is an SVG property that is not defined in any CSS standard. However, Gecko and WebKit browsers let you apply this property to HTML and XML content on Windows and Linux. 

Note: This property has no effect on Mac OS X.

One very visible effect is: optimizeLegibility enables ligatures (ff, fi, fl etc.) in text smaller than 20px for some fonts (for example, Microsoft's Calibri, Candara, Constantia and Corbel or the DejaVu font family).

  • {{ Xref_cssinitial() }}: auto
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: yes
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: ?

Syntax

text-rendering:  auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit

Values

auto
The browser makes educated guesses about when to optimize for speed, legibility, and geometric precision while drawing text. For differences in how this value is interpreted by the browser, see the compatibility table.
optimizeSpeed
The browser emphasizes rendering speed over legibility and geometric precision when drawing text. It disables kerning and ligatures.
optimizeLegibility
The browser emphasizes legibility over rendering speed and geometric precision. This enables kerning and optional ligatures.
geometricPrecision
The browser emphasizes geometric precision over rendering speed and legibility. Certain aspects of fonts—such as kerning—don't scale linearly, so geometricPrecision can make text using those fonts look good.

WebKit precisely applies the specified value, but Gecko treats the value the same as optimizeLegibility>/code>.

Examples

/* make sure all fonts in the HTML document display in all its glory,
   but avoid inadequate ligatures in class foo elements */

body  { text-rendering: optimizeLegibility; }
.foo  { text-rendering: optimizeSpeed; }

Live Example

CSS code Kerning Ligatures
font: 19.9px 'DejaVu Serif',Constantia; LYoWAT ff fi fl ffl
font: 20px 'DejaVu Serif',Constantia; LYoWAT ff fi fl ffl
font: 3em 'DejaVu Serif',Constantia;
text-rendering: optimizeSpeed;
LYoWAT ff fi fl ffl
font: 3em 'Dejavu Serif',Constantia;
text-rendering: optimizeLegibility;
LYoWAT ff fi fl ffl

Notes

The 20px threshold value of the auto keyword can be changed by changing the browser.display.auto_quality_min_font_size preference.

{{ gecko_callout_heading("2.0") }}

The optimizeSpeed option has no effect on Gecko 2.0 {{ geckoRelease("2.0") }}, because the standard code for text rendering is already very fast and there is not a faster code path at this time. See {{ bug("595688") }} for details.

Browser compatibility

{{ CompatibilityTable() }}

Work is continuing on({{ Webkitbug("41363") }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support for Windows and Linux

4.0 

 

3.0 (1.9) {{ CompatNo() }} {{ CompatNo() }} 5.0 (532.5)
Basic support for other operating systems {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
auto

Chrome treats this as optimizeSpeed

Work is continuing on{{ Webkitbug("41363") }}

If the font size is 20 px or higher, Gecko browsers use optimizeLegibility; for smaller text, they use optimizeSpeed. {{ CompatNo() }} {{ CompatNo() }} Safari treats this as optimizeSpeed.

Work is continuing on{{ Webkitbug("41363") }}

geometricPrecision

Chrome 13 supports true geometric precision, without rounding up or down to the nearest supported font size in the operating system.

Introduced in WebKit 535.1   {{ Webkitbug("60317") }}

Defaults to optimizeLegibility for text > 20px  {{ CompatNo() }}  {{ CompatNo() }}  
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

Specifications

This is an SVG property, it is not defined in any CSS standard. Gecko (Firefox) and WebKit apply text-rendering also to HTML and XML content.

See also

{{ CSS_Reference:Text() }}

Revision Source

<h3>Summary</h3>
<p>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. The text-rendering property is an SVG property that is not defined in any CSS standard. However, Gecko and WebKit browsers let you apply this property to HTML and XML content on Windows and Linux. </p>
<div class="note"><strong>Note:</strong> This property has no effect on Mac OS X.</div>
<p>One very visible effect is:<code> optimizeLegibility </code>enables ligatures (ff, fi, fl etc.) in text smaller than 20px for some fonts (for example, Microsoft's<em> Calibri, Candara, Constantia and Corbel</em> or the <em>DejaVu</em> font family).</p>
<ul> <li>{{ Xref_cssinitial() }}: auto</li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: yes</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: ?</li>
</ul>
<h3>Syntax</h3>
<pre class="eval">text-rendering:  auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit</pre>
<h3>Values</h3>
<dl> <dt><code>auto</code></dt> <dd>The browser makes educated guesses about when to optimize for speed, legibility, and geometric precision while drawing text. For differences in how this value is interpreted by the browser, see the compatibility table.</dd> <dt><code>optimizeSpeed</code></dt> <dd>The browser emphasizes rendering speed over legibility and geometric precision when drawing text. It disables kerning and ligatures.</dd> <dt><code>optimizeLegibility</code></dt> <dd>The browser emphasizes legibility over rendering speed and geometric precision. This enables kerning and optional ligatures.</dd> <dt><code>geometricPrecision</code></dt> <dd>The browser emphasizes geometric precision over rendering speed and legibility. Certain aspects of fonts—such as kerning—don't scale linearly, so geometricPrecision can make text using those fonts look good. <p>WebKit precisely applies the specified value, but Gecko treats the value the same as <code>optimizeLegibility&gt;/code&gt;.</code></p></dd>
</dl>
<h3>Examples</h3>
<pre>/* make sure all fonts in the HTML document display in all its glory,
   but avoid inadequate ligatures in class foo elements */

body  { text-rendering: optimizeLegibility; }
.foo  { text-rendering: optimizeSpeed; }</pre>
<h4>Live Example</h4>
<table class="standard-table"> <tbody> <tr> <th>CSS code</th> <th>Kerning</th> <th>Ligatures</th> </tr> <tr style="font: 19.9px 'DejaVu Serif',Constantia"> <td style="font:medium monospace">font: 19.9px 'DejaVu Serif',Constantia;</td> <td>LYoWAT</td> <td>ff fi fl ffl</td> </tr> <tr style="font: 20px 'DejaVu Serif',Constantia"> <td style="font:medium monospace">font: 20px 'DejaVu Serif',Constantia;</td> <td>LYoWAT</td> <td>ff fi fl ffl</td> </tr> <tr style="font: 3em 'DejaVu Serif',Constantia; text-rendering:optimizeSpeed;"> <td style="font:medium monospace">font: 3em 'DejaVu Serif',Constantia;<br> text-rendering: optimizeSpeed;</td> <td>LYoWAT</td> <td>ff fi fl ffl</td> </tr> <tr style="font: 3em 'Dejavu Serif',Constantia; text-rendering:optimizeLegibility;"> <td style="font:medium monospace">font: 3em 'Dejavu Serif',Constantia;<br> text-rendering: optimizeLegibility;</td> <td>LYoWAT</td> <td>ff fi fl ffl</td> </tr> </tbody>
</table>
<h3>Notes</h3>
<p>The 20px threshold value of the<code> auto </code>keyword can be changed by changing the <code>browser.display.auto_quality_min_font_size</code> preference.</p>
<div class="geckoVersionNote">
<p>{{ gecko_callout_heading("2.0") }}</p>
<p>The <code>optimizeSpeed</code> option has no effect on Gecko 2.0 {{ geckoRelease("2.0") }}, because the standard code for text rendering is already very fast and there is not a faster code path at this time. See {{ bug("595688") }} for details.</p>
</div>
<h3 name="Browser_Compatibility">Browser compatibility</h3>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
<p>Work is continuing on({{ Webkitbug("41363") }}</p>
<table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari (WebKit)</th> </tr> <tr> <td>Basic support for Windows and Linux</td> <td> <p>4.0 </p> <p> </p> </td> <td><strong>3.0</strong> (1.9)</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>5.0 (532.5)</td> </tr> <tr> <td>Basic support for other operating systems</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> </tr> <tr> <td><code>auto</code></td> <td> <p>Chrome treats this as <code>optimizeSpeed</code>. </p> <p>Work is continuing on{{ Webkitbug("41363") }}</p> </td> <td>If the font size is 20 px or higher, Gecko browsers use <code>optimizeLegibility</code>; for smaller text, they use <code>optimizeSpeed</code>.</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>Safari treats this as <code>optimizeSpeed</code>. <p>Work is continuing on{{ Webkitbug("41363") }}</p> </td> </tr> <tr> <td><code>geometricPrecision</code></td> <td> <p>Chrome 13 supports true geometric precision, without rounding up or down to the nearest supported font size in the operating system.</p> <p>Introduced in WebKit 535.1   {{ Webkitbug("60317") }}</p> </td> <td>Defaults to <code>optimizeLegibility</code> for text &gt; 20px</td> <td> {{ CompatNo() }}</td> <td> {{ CompatNo() }}</td> <td> </td> </tr> </tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody>
</table>
</div>
<h3>Specifications</h3>
<p>This is an SVG property, it is not defined in any CSS standard. Gecko (Firefox) and WebKit apply<code> text-rendering </code>also to HTML and XML content.</p>
<ul> <li><a class="external" href="http://www.w3.org/TR/SVG11/painting.html#TextRenderingProperty" title="http://www.w3.org/TR/SVG11/painting.html#TextRenderingProperty">SVG 1.1 Painting #text-rendering</a></li>
</ul>
<h3>See also</h3>
<p>{{ CSS_Reference:Text() }}</p>
Revert to this revision