TextMetrics

Sie lesen die englische Version dieses Inhalts, da für dieses Gebietsschema noch keine Übersetzung vorhanden ist. Helfen Sie uns, diesen Artikel zu übersetzen!

The TextMetrics interface represents the dimensions of a piece of text in the canvas, as created by the CanvasRenderingContext2D.measureText() method.

Properties

TextMetrics.width Read only
Is a double giving the calculated width of a segment of inline text in CSS pixels. It takes into account the current font of the context.
TextMetrics.actualBoundingBoxLeft Read only
Is a double giving the distance parallel to the baseline from the alignment point given by the CanvasRenderingContext2D.textAlign property to the left side of the bounding rectangle of the given text, in CSS pixels.
TextMetrics.actualBoundingBoxRight Read only
Is a double giving the distance parallel to the baseline from the alignment point given by the CanvasRenderingContext2D.textAlign property to the right side of the bounding rectangle of the given text, in CSS pixels.
TextMetrics.fontBoundingBoxAscent Read only
Is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline attribute to the top of the highest bounding rectangle of all the fonts used to render the text, in CSS pixels.
TextMetrics.fontBoundingBoxDescent Read only
Is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline attribute to the bottom of the bounding rectangle of all the fonts used to render the text, in CSS pixels.
TextMetrics.actualBoundingBoxAscent Read only
Is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline attribute to the top of the bounding rectangle used to render the text, in CSS pixels.
TextMetrics.actualBoundingBoxDescent Read only
Is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline attribute to the bottom of the bounding rectangle used to render the text, in CSS pixels.
TextMetrics.emHeightAscent Read only
Is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline property to the top of the em square in the line box, in CSS pixels.
TextMetrics.emHeightDescent Read only
Is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline property to the bottom of the em square in the line box, in CSS pixels.
TextMetrics.hangingBaseline Read only
Is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline property to the hanging baseline of the line box, in CSS pixels.
TextMetrics.alphabeticBaseline Read only
Is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline property to the alphabetic baseline of the line box, in CSS pixels.
TextMetrics.ideographicBaseline Read only
Is a double giving the distance from the horizontal line indicated by the CanvasRenderingContext2D.textBaseline property to the ideographic baseline of the line box, in CSS pixels.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'TextMetrics' in that specification.
Living Standard Initial definition

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
TextMetricsChrome Full support 4Edge Full support YesFirefox Full support 1.5IE Full support 9Opera Full support 9Safari Full support 3.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 31Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
actualBoundingBoxAscent
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS Full support YesSamsung Internet Android ?
actualBoundingBoxDescent
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS Full support YesSamsung Internet Android ?
actualBoundingBoxLeft
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS Full support YesSamsung Internet Android ?
actualBoundingBoxRight
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS Full support YesSamsung Internet Android ?
alphabeticBaseline
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS Full support YesSamsung Internet Android ?
emHeightAscent
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS Full support YesSamsung Internet Android ?
emHeightDescent
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS Full support YesSamsung Internet Android ?
fontBoundingBoxAscent
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS Full support YesSamsung Internet Android ?
fontBoundingBoxDescent
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS No support NoSamsung Internet Android ?
hangingBaseline
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS Full support YesSamsung Internet Android ?
ideographicBaseline
Experimental
Chrome Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge No support NoFirefox No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
IE No support NoOpera ? Safari Full support YesWebView Android No support NoChrome Android Full support Yes
Disabled
Full support Yes
Disabled
Disabled This feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android No support No
Notes
No support No
Notes
Notes Firefox does not implement this feature yet. See the related bug 1102584.
Opera Android ? Safari iOS Full support YesSamsung Internet Android ?
width
Experimental
Chrome Full support 4Edge Full support 12Firefox Full support 1.5IE Full support 9Opera Full support 9Safari Full support 3.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 31Opera Android Full support YesSafari iOS Full support 3.2Samsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also