SVGTextPathElement: spacing プロパティ
Baseline
広く利用可能
この機能は広く実装されており、多くのバージョンの端末やブラウザーで動作します。2015年7月以降、すべてのブラウザーで利用可能です。
spacing は SVGTextPathElement インターフェイスの読み取り専用プロパティで、この <textPath> 要素の spacing 属性を反映します。これはこのインターフェイスで定義されている TEXTPATH_SPACINGTYPE_* 定数のいずれかを取ります。
値
SVGAnimatedEnumeration オブジェクトです。
例
>spacing プロパティへのアクセス
html
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="200">
<defs>
<path id="myPath" d="M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80" />
</defs>
<text font-size="20" fill="blue">
<textPath id="myTextPath" href="proxy.php?url=https%3A%2F%2Fdeveloper.mozilla.org%2Fja%2Fdocs%2FWeb%2FAPI%2FSVGTextPathElement%2Fspacing%23myPath" spacing="auto">
このテキストはパスに沿います。
</textPath>
</text>
</svg>
js
const textPath = document.getElementById("myTextPath");
// spacing プロパティへのアクセス
console.log(textPath.spacing.baseVal); // 出力結果: 1 (TEXTPATH_SPACINGTYPE_AUTO)
仕様書
| 仕様書 |
|---|
| Scalable Vector Graphics (SVG) 2> # __svg__SVGTextPathElement__spacing> |