SVG 支持

从 Windows 10 周年更新开始,Direct2D 支持呈现包含 SVG 字形轮廓的 颜色字体,如 OpenType 规范 中所述(请参阅 SVG 表)。 从 Windows 10 创意者更新开始,Direct2D 还支持呈现独立的 SVG 图像。 但是,OpenType SVG 字体中不允许某些 SVG 功能,Direct2D 目前不支持某些 SVG 功能。  

本主题标识 Windows 10 周年更新和更新版中 Direct2D 支持的一组 SVG 1.1 功能。 本文档适用于 OpenType 字体和独立 SVG 图像中的 SVG。

支持的 SVG 元素和属性

Direct2D 支持呈现以下 SVG 元素和每个元素的关联属性。 忽略其他元素和常规属性。

元素 支持的常规属性
id, style, transform, cx, cy, r
clipPath id, style, transform, clipPathUnits
id,样式,转换
desc* id
省略号 id, style, transform, cx, cy, rx, ry
g id,样式,转换
图像 id, style, transform, x, y, width, height, preserveAspectRatio, xlink:href
id, style, transform, x1, y1, x2, y2
linearGradient id, style, x1, y1, x2, y2, gradientUnits, gradientTransform, spreadMethod, xlink:href
路径 id, style, transform, d
多边形 id, 样式, 转换, 点
折线 id, 样式, 转换, 点
radialGradient id, style, cx, cy, r, fx, fy, gradientUnits, gradientTransform, spreadMethod, xlink:href
rect id, style, transform, x, y, width, height, rx, ry
停止 id、style、offset
svg id, style, x, y, width, height, viewBox, preserveAspectRatio
游戏* id
使用 id, style, transform, x, y, width, height, xlink:href

 

* 仅在 Windows 10 创意者更新和更新中受支持

支持的 SVG 演示文稿属性

Direct2D 还支持以下演示文稿属性。 可以在任何 SVG 元素上指定这些元素,但它们仅影响 SVG 规范中所述的某些元素的外观(请参阅 演示文稿属性)。

  • clip-path
  • clip-rule
  • 颜色
  • 显示*
  • 填补
  • fill-opacity
  • fill-rule
  • 不透明度
  • 溢出
  • stop-color
  • stop-opacity
  • 中风
  • stroke-dasharray
  • stroke-dashoffset
  • stroke-linecap
  • stroke-linejoin
  • stroke-miterlimit
  • stroke-opacity
  • 笔划宽度
  • 可见性*

* 仅在 Windows 10 创意者更新和更新中受支持

不支持的 SVG 功能

不支持的元素和属性

上述列表中未包含的任何元素或属性都被视为 Direct2D 不支持。 分析包含不受支持的元素或属性的 SVG 内容时,将忽略不受支持的实体。 其余内容尽可能忠实地呈现。

不支持的长度单位

自 Windows 10 周年更新起,Direct2D 仅支持用户空间长度值和百分比长度值。 不支持单元后缀(如“mm”或“em”)的长度。

从 Windows 10 Fall Creators Update 开始,Direct2D 还支持绝对单位标识符:px、pt、pc、cm、mm 和 in。 不支持相对单位标识符(em,例如)。

不受支持的映像源

仅当图像元素的 xlink:href 属性设置为 base64 编码的图像时,才支持该元素。 不支持远程引用。