<glyph>

已棄用:此功能不再推薦。雖然某些瀏覽器可能仍然支援它,但它可能已從相關的 Web 標準中刪除,可能正在被刪除,或者可能僅出於相容性目的而保留。避免使用它,並儘可能更新現有程式碼;請檢視此頁面底部的相容性表格,以指導您的決定。請注意,此功能可能隨時停止工作。

一個<glyph>在 SVG 字型中定義單個字形。

使用環境

類別文字內容元素
允許的內容以下元素的任意數量,可以按任何順序排列
動畫元素
描述性元素
形狀元素
結構元素
漸變元素
<a>, <clipPath>, <cursor>, <filter>, <font>, <font-face>, <foreignObject>, <image>, <marker>, <mask>, <pattern>, <script>, <style>, <switch>, <text>, <view>

屬性

DOM 介面

此元素實現了SVGGlyphElement介面。

示例

SVG

html
<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 embedded font!
  </text>
</svg>

結果

規範

規範
可縮放向量圖形 (SVG) 1.1(第二版)
# GlyphElement

瀏覽器相容性

BCD 表格僅在啟用 JavaScript 的瀏覽器中載入。

另請參閱