非常教程

SVG参考手册

分类 | Elements

glyph

弃用

该功能已从Web标准中删除。尽管一些浏览器可能仍然支持,但它正在被丢弃。避免使用它并尽可能更新现有的代码; 请参阅本页面底部的兼容性表格来指导您的决定。请注意,此功能可能随时停止工作。

A <glyph>在SVG字体中定义单个字形。

用法上下文

分类

文本内容元素

允许的内容

任意数量的下列元素,以任何顺序排列:动画元素描述元素图形元素结构元素渐变元素<a>, <altGlyphDef>, <clipPath>, <color-profile>, <cursor>, <filter>, <font>, <font-face>, <foreignObject>, <image>, <marker>, <mask>, <pattern>, <script>, <style>, <switch>, <text>, <view>

属性

全局属性

  • Core attributes
  • Presentation attributes
  • class
  • style

具体属性

  • d
  • horiz-adv-x
  • vert-origin-x
  • vert-origin-y
  • vert-adv-y
  • unicode
  • glyph-name
  • orientation
  • arabic-form
  • lang

DOM接口

这个元素实现了SVGGlyphElement接口。

示例

SVG

<svg width="400px" height="300px" version="1.1"
    xmlns="http://www.w3.org/2000/svg">
<!-- Example copied from https://www.w3.org/TR/SVG/fonts.html#GlyphElement -->
  <defs>

    <font id="Font1" horiz-adv-x="1000">
      <font-face font-family="Super Sans" font-weight="bold" font-style="normal"
          units-per-em="1000" cap-height="600" x-height="400"
          ascent="700" descent="300"
          alphabetic="0" mathematical="350" ideographic="400" hanging="500">
        <font-face-src>
          <font-face-name name="Super Sans Bold"/>
        </font-face-src>
      </font-face>

      <missing-glyph><path d="M0,0h200v200h-200z"/></missing-glyph>
      <glyph unicode="!" horiz-adv-x="80" d="M0,0h200v200h-200z"></glyph>
      <glyph unicode="@" d="M0,50l100,300l400,100z"></glyph>
    </font>
  </defs>
  <text x="100" y="100" 
      style="font-family: 'Super Sans', Helvetica, sans-serif;
             font-weight: bold; font-style: normal">Text 
    using embe@dded font!</text>
</svg>

结果

产品规格

Specification

Status

Comment

Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of '<glyph>' in that specification.

Recommendation

Initial definition

浏览器兼容性

Feature

Chrome

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

?

?

?

?

?

Feature

Android

Firefox Mobile (Gecko)

IE Phone

Opera Mobile

Safari Mobile

Basic support

?

?

?

?

?

SVG

可缩放矢量图形是基于可扩展标记语言(标准通用标记语言的子集),用于描述二维矢量图形的一种图形格式。它由万维网联盟制定,是一个开放标准。