Automattic / Automattic/node-canvas

Mark TextMetrics#fontBoundingBoxAscent etc. as unimplemented

Open
#2,364 3 comments 2 reactions 0 assignees View on GitHub
Feature Text & Fonts
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

## Issue

I have some need to measure the height of fonts.
But `TextMeasure.fontBoundingBoxAscent` is always `undefined`.

[It seems that these API are not implemented](https://github.com/Automattic/node-canvas/blob/25fbac52c8f2d63468992d7c9f110aff6ef58dfc/src/CanvasRenderingContext2d.cc#L2715).
However, [the typescript definition provides the relevant definitions](https://github.com/Automattic/node-canvas/blob/25fbac52c8f2d63468992d7c9f110aff6ef58dfc/index.d.ts#L135).

Maybe it's better to mark these API as unimplemented.

## Steps to Reproduce

```js
var Canvas = require('canvas');
var canvas = Canvas.createCanvas(200, 200);
var ctx = canvas.getContext('2d');

ctx.font = "Arial";
const measure = ctx.measureText('test');

console.log(measure.fontBoundingBoxAscent); // undefined;
console.log(measure);
/*
{
width: 16.416015625,
actualBoundingBoxLeft: -1,
actualBoundingBoxRight: 17.0712890625,
actualBoundingBoxAscent: 7,
actualBoundingBoxDescent: 0,
emHeightAscent: 11,
emHeightDescent: 3,
alphabeticBaseline: 1
}
*/
```

## Your Environment
* Version of node-canvas (output of `npm list canvas` or `yarn list canvas`): canvas 2.11.2
* Environment (e.g. node 20.9.0 on macOS 14.1.1): node v18.18.2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.