Automattic/node-canvas

fontBoundingBox is not implemented

Ouverte

#1 940 ouverte le 29 nov. 2021

 (1 commentaire) (2 réactions) (0 personne assignée)JavaScript (1 195 forks)batch import
Help wantedText & Fonts

Métriques du dépôt

Stars
 (10 687 étoiles)
Métriques de merge PR
 (Merge moyen 34j 18h) (2 PRs mergées en 30 j)

Description

Issue or Feature

Hi! I was expecting to use fontBoundingBox, but as it turns out there's a TODO in code left and it isn't done. I saw some PR's that said it couldn't be done. Could there be some kind of resolution or workaround to experience the same effect as fontBoundingBox?

In the visible image, I would like to get the blue part. (fontBoundingBox) image

Steps to Reproduce

import Canvas from 'canvas';

const canvas = Canvas.createCanvas(10, 10);

const ctx = canvas.getContext('2d')
const measure = ctx.measureText("woohoo!");

console.log(measure.fontBoundingBoxAscent) // undefined :(

Your Environment

  • Version of node-canvas (output of npm list canvas or yarn list canvas): canvas@2.8.0
  • Environment (e.g. node 4.2.0 on Mac OS X 10.8): v16.4.2 on Windows

Guide contributeur