Редагувати

Поділитися через


SVG Support

Beginning in Windows 10 Anniversary Update, Direct2D supports rendering color fonts that contain SVG glyph outlines, as described in the OpenType specification (see The SVG table). Beginning in Windows 10 Creators Update, Direct2D also supports rendering standalone SVG images. However, certain SVG features are disallowed within OpenType SVG fonts, and certain SVG features are currently unsupported by Direct2D.  

This topic identifies the set of SVG 1.1 features supported by Direct2D in Windows 10 Anniversary Update and newer. This document applies to SVG in OpenType fonts as well as standalone SVG images.

Supported SVG elements and attributes

Direct2D supports rendering the following SVG elements and the associated attributes for each element. Other elements and regular attributes are ignored.

Element Supported regular attributes
circle id, style, transform, cx, cy, r
clipPath id, style, transform, clipPathUnits
defs id, style, transform
desc* id
ellipse id, style, transform, cx, cy, rx, ry
g id, style, transform
image id, style, transform, x, y, width, height, preserveAspectRatio, xlink:href
line id, style, transform, x1, y1, x2, y2
linearGradient id, style, x1, y1, x2, y2, gradientUnits, gradientTransform, spreadMethod, xlink:href
path id, style, transform, d
polygon id, style, transform, points
polyline id, style, transform, points
radialGradient id, style, cx, cy, r, fx, fy, gradientUnits, gradientTransform, spreadMethod, xlink:href
rect id, style, transform, x, y, width, height, rx, ry
stop id, style, offset
svg id, style, x, y, width, height, viewBox, preserveAspectRatio
title* id
use id, style, transform, x, y, width, height, xlink:href

 

* Only supported in Windows 10 Creators Update and newer

Supported SVG presentation attributes

Direct2D also supports the following presentation attributes. These can be specified on any SVG elements, but they only affect the appearance of certain elements as described in the SVG specification (see Presentation attributes).

  • clip-path
  • clip-rule
  • color
  • display*
  • fill
  • fill-opacity
  • fill-rule
  • opacity
  • overflow
  • stop-color
  • stop-opacity
  • stroke
  • stroke-dasharray
  • stroke-dashoffset
  • stroke-linecap
  • stroke-linejoin
  • stroke-miterlimit
  • stroke-opacity
  • stroke-width
  • visibility*

* Only supported in Windows 10 Creators Update and newer

Unsupported SVG features

Unsupported elements and attributes

Any element or attribute not included in the above lists is considered unsupported by Direct2D. When parsing SVG content that contains an unsupported element or attribute, the unsupported entity is ignored. The remainder of the content is rendered as faithfully as possible.

Unsupported length units

As of Windows 10 Anniversary Update, Direct2D only supports user-space length values and percentage length values. Lengths with unit suffixes, like “mm” or “em,” are unsupported.

Starting in Windows 10 Fall Creators Update, Direct2D also supports absolute unit identifiers: px, pt, pc, cm, mm, and in. Relative unit identifiers (em, ex) are not supported.

Unsupported image sources

The image element is only supported if its xlink:href attribute is set to a base64-encoded image. Remote references are not supported.