Automattic / Automattic/node-canvas

emHeightDescent and emHeightAscent return value that should returns from fontBoundingBoxAscent and fontBoundingBoxDescent

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

Description

According to specification, fontBoundingBoxAscent returns following.
> The distance from the horizontal line indicated by the [textBaseline](https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textbaseline) attribute to the [ascent metric](https://drafts.csswg.org/css-inline/#ascent-metric) of the [first available font](https://drafts.csswg.org/css-fonts/#first-available-font).

ascent metric is generally takes from font metrics.
(see https://drafts.csswg.org/css-inline/#ascent-descent)

node-canvas seems implemented it in `emHeightAscent`.
https://github.com/Automattic/node-canvas/blob/master/src/CanvasRenderingContext2d.cc#L2778-L2779

about em-square, ascent and descent, see https://learn.microsoft.com/en-us/typography/opentype/spec/ttch01#funits-and-the-em-square .

my investigation result on Firefox.
![image](https://github.com/user-attachments/assets/214d6f75-3945-43e7-bdb4-69ffd4839fef)

related https://github.com/Automattic/node-canvas/issues/1940

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

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.