SVGTextContentElement: getRotationOfChar()-Methode

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Die getRotationOfChar()-Methode der SVGTextContentElement-Schnittstelle repräsentiert die Rotation eines typografischen Zeichens.

Syntax

js
SVGTextContentElement.getRotationOfChar(index)

Parameter

index

Ein integer; der Index des Zeichens.

Rückgabewert

Ein Float; der Rotationswinkel des Zeichens in Grad.

Ausnahmen

IndexSizeError DOMException

Wird ausgelöst, wenn kein Zeichen an index gefunden wird.

Beispiele

Ermitteln der Rotation eines Zeichens

html
<svg width="200" height="100">
  <text id="exampleText" x="10" y="40" writing-mode="vertical-rl">
    Hello, SVG
  </text>
</svg>
js
const textElement = document.getElementById("exampleText");

// Get the rotation of the first character "H"
const rotation = textElement.getRotationOfChar(0);

console.log(extent); // Output: 90

Spezifikationen

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGTextContentElement__getRotationOfChar

Browser-Kompatibilität

BCD tables only load in the browser

Siehe auch