The creator of SVG content might want to provide a hint about what tradeoffs to make as the browser renders text. The text-rendering
attribute provides these hints.
As a presentation attribute, it also can be used as a property directly inside a CSS stylesheet, see css text-rendering
for further information
Categories | Presentation attribute |
---|---|
Value | auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit |
Animatable | Yes |
Normative document | SVG 1.1 (2nd Edition) |
<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="660" height="40" text-rendering="optimizeLegibility"> <link xmlns="http://www.w3.org/1999/xhtml" href='http://fonts.googleapis.com/css?family=Sofadi+One' rel='stylesheet' type='text/css' /> <style> text {font: 30px 'Sofadi One', cursive;} </style> <g> <text y="30">The quick brown fox jumps over the lazy dog.</text> </g> </svg>
optimizeLegibility (first) и geometricPrecision (second)
Similarly acts css text-rendering
<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="660" height="40"> <link xmlns="http://www.w3.org/1999/xhtml" href='http://fonts.googleapis.com/css?family=Sofadi+One' rel='stylesheet' type='text/css' /> <style> text { font: 30px 'Sofadi One', cursive; text-rendering: optimizeLegibility; } </style> <g> <text y="30">The quick brown fox jumps over the lazy dog.</text> </g> </svg>
The following elements can use the text-rendering
attribute
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | ? | ? | ? | ? | ? | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | ? | ? | ? | ? | ? | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-rendering