SVGTextContentElement: getRotationOfChar() メソッド
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.
getRotationOfChar()
は SVGTextContentElement
インターフェイスのメソッドで、組版された文字の回転を表します。
構文
js
getRotationOfChar(index)
引数
index
-
integer
です。文字のインデックスです。
返値
float 値です。文字の回転角を角度で表します。
例外
IndexSizeError
DOMException
-
index
の位置に文字がなかった場合に発生します。
例
Getting the Rotation of a Character
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");
// 最初の文字 "H" の回転角を取得
const rotation = textElement.getRotationOfChar(0);
console.log(extent); // 出力: 90
仕様書
Specification |
---|
Scalable Vector Graphics (SVG) 2 # __svg__SVGTextContentElement__getRotationOfChar |