The read-only fontBoundingBoxAscent
property of the TextMetrics
interface 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.
Examples
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const text = ctx.measureText('foo'); // returns TextMetrics object
text.fontBoundingBoxAscent; // 10;
Specifications
Specification |
HTML Living StandardThe definition of 'TextMetrics.fontBoundingBoxAscent' in that specification. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome Full support Yes Full support Yes Disabled' This feature is behind the |
Edge Full support 79 Full support 79 Disabled' From version 79: this feature is behind the |
Firefox Full support 74 Full support 74 Disabled' From version 74: this feature is behind the |
IE
No support No |
Opera
? |
Safari
Full support Yes |
WebView Android
No support No |
Chrome Android Full support Yes Full support Yes Disabled' This feature is behind the |
Firefox Android
No support No |
Opera Android
? |
Safari iOS
Full support Yes |
Samsung Internet Android
No support No |
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.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
See also
TextMetrics.fontBoundingBoxAscent by Mozilla Contributors is licensed under CC-BY-SA 2.5.