SVGTextContentElement

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, SVGTRefElement, SVGAltGlyphElement and SVGTextPathElement.

Constants

Constant Value Description
LENGTHADJUST_UNKNOWN 0 Some other value.
LENGTHADJUST_SPACING 1 The spacing keyword.
LENGTHADJUST_SPACINGANDGLYPHS 2 The spacingAndGlyphs keyword.

Properties

This interface also inherits properties from its parent, SVGGraphicsElement.

SVGTextContentElement.textLength Read only
An SVGAnimatedLength reflecting the textLength attribute of the given element.
SVGTextContentElement.lengthAdjust Read only
An SVGAnimatedEnumeration reflecting the lengthAdjust attribute of the given element. The numeric type values represent one of the constant values above.

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.

Note: In SVG 1.1 this method returned an SVGPoint.

SVGTextContentElement.getEndPositionOfChar()
Returns a DOMPoint representing the trailing position of a typographic character after text layout has been performed.

Note: In SVG 1.1 this method returned an SVGPoint.

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

Specification Status Comment
Scalable Vector Graphics (SVG) 2
The definition of 'SVGTextContentElement' in that specification.
Candidate Recommendation Changed inheritance from SVGElement to SVGGraphicsElement and getStartPositionOfChar() and removed implementations of SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGStylable interfaces and getEndPositionOfChar() to return a DOMPoint instead of an SVGPoint.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'SVGTextContentElement' in that specification.
Recommendation Initial definition

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
SVGTextContentElementChrome Full support YesEdge Full support 12Firefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
getCharNumAtPositionChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
getComputedTextLengthChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
getEndPositionOfCharChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
getExtentOfCharChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
getNumberOfCharsChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
getRotationOfCharChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
getStartPositionOfCharChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
getSubStringLengthChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
lengthAdjustChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
selectSubString
Deprecated
Chrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
textLengthChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support
Full support
Compatibility unknown
Compatibility unknown
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.