大网数据广告活动
Web 标准与前端开发

SVGTextContentElement

· 52CE 我爱测

The **`SVGTextContentElement`** interface is implemented by elements that support rendering child text content. It is inherited by various text-related interfaces, such as SVGTextElement, SVGTSpanElement, and SVGTextPathElement.

SVG

The SVGTextContentElement interface is implemented by elements that support rendering child text content. It is inherited by various text-related interfaces, such as SVGTextElement, SVGTSpanElement, and SVGTextPathElement.

Static properties

  • LENGTHADJUST_UNKNOWN (0)
    • : The type is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
  • LENGTHADJUST_SPACING (1)
    • : Corresponds to the value spacing.
  • LENGTHADJUST_SPACINGANDGLYPHS (2)
    • : Corresponds to the value spacingAndGlyphs.

Instance properties

This interface also inherits properties from its parent, SVGGraphicsElement.

  • SVGTextContentElement.textLength
    • : An SVGAnimatedLength reflecting the textLength attribute of the given element.
  • SVGTextContentElement.lengthAdjust
    • : An SVGAnimatedEnumeration reflecting the lengthAdjust attribute of the given element. The numeric type values represent one of the LENGTHADJUST_* constant values.

Instance methods

This interface also inherits methods from its parent, SVGGraphicsElement.

  • SVGTextContentElement.getNumberOfChars()
    • : Returns a long representing the total number of addressable characters available for rendering within the current element, regardless of whether they will be rendered.
  • SVGTextContentElement.getComputedTextLength()
    • : Returns a float representing the computed length for the text within the element.
  • SVGTextContentElement.getSubStringLength()
    • : Returns a float representing the computed length of the formatted text advance distance for a substring of text within the element. Note that this method only accounts for the widths of the glyphs in the substring and any extra spacing inserted by the CSS 'letter-spacing' and 'word-spacing' properties. Visual spacing adjustments made by the 'x' attribute is ignored.
  • SVGTextContentElement.getStartPositionOfChar()
    • : Returns a DOMPoint representing the position of a typographic character after text layout has been performed.
  • SVGTextContentElement.getEndPositionOfChar()
    • : Returns a DOMPoint representing the trailing position of a typographic character after text layout has been performed.
  • SVGTextContentElement.getExtentOfChar()
    • : Returns a DOMRect representing the computed tight bounding box of the glyph cell that corresponds to a given typographic character.
  • SVGTextContentElement.getRotationOfChar()
    • : Returns a float representing the rotation of typographic character.
  • SVGTextContentElement.getCharNumAtPosition()
    • : Returns a long representing the character which caused a text glyph to be rendered at a given position in the coordinate system. Because the relationship between characters and glyphs is not one-to-one, only the first character of the relevant typographic character is returned.
  • SVGTextContentElement.selectSubString()
    • : Selects text within the element.

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。