TextMetrics: hangingBaseline プロパティ
Baseline
2023
Newly available
Since October 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
メモ: この機能はウェブワーカー内で利用可能です。
hangingBaseline は TextMetrics インターフェイスの読み取り専用プロパティで、double 型であり、CanvasRenderingContext2D.textBaseline プロパティで示される水平線から、行ボックスのハンギングベースラインまでの距離を CSS ピクセル単位で返します。
例
js
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
const text = ctx.measureText("foo"); // TextMetrics オブジェクトを返す
text.hangingBaseline; // 6.078125;
仕様書
| Specification |
|---|
| HTML> # dom-textmetrics-hangingbaseline-dev> |